Reputation: 12915
I'm trying to detect if a user moves off of a field using the "tab" button - if so, I'd like to save the data.
In this case, there are two fields being saved when the last field is exited via tab. If I click "save" manually, both fields update correctly. If I use TAB, only the first field gets saved, and the old field doesn't save the new data. This tells me that somehow the "keydown" binding isn't seeing the new data.
If I debug locally and hover over "data" in the tabOut method, I see that the first field has new data, but the second field has old data.
fiddle: http://jsfiddle.net/PTSkR/18/
Any help would be much appreciated!
view:
<div class="span5 side-study-box">
<textarea data-bind="value: sides()[0].content"></textarea>
</div>
<div class="span5 side-study-box">
<textarea data-bind="value: sides()[1].content, event: { keydown: tabOut }"></textarea>
</div>
tabOut function:
self.tabOut = function (data, event) {
if (event.keyCode == 9) {
debugger;
self.save();
};
return true;
};
Upvotes: 0
Views: 425
Reputation: 37366
Have you tried adding "valueUpdate:'afterkeydown'" bingings to your textboxes?
Upvotes: 2