A hypothetical example - you have a collection of "Items", where each item has a quantity and price stored in db.
This quantity is an input field.
We want the database to be updated when the quantity changes - without the send button. There are several ways around this. Two examples:
Update db to "changed":
'change input.qty': function (evt) {
var qty = $(evt.target).val();
if (qty==null){
qty=0;
};
Items.update(this._id,{$set:{quantity: Number(qty)}});
},
Update db to "keyup":
'keyup input.qty': function (evt) {
var qty = $(evt.target).val();
if (qty==null){
qty=0;
};
Items.update(this._id,{$set:{quantity: Number(qty)}});
},
1 is more efficient - it only makes an update call once, after the user clicked outside the input field. However, this is worse because updates do not appear on the page as you type. (For example, say the price field is calculated reactively based on your input quantity)
2 - , (.. 103.58 FIVE )
?