Amit Kumar Kannaujiya Amit Kumar Kannaujiya - 6 months ago 18
jQuery Question

listen to change input in backbone

How to register to change in text of input in backbone. I have to listen every time text in label changes .
I had tried this but not worked .

var cashback = CustomBackbone.Components.LabeledInput({
state: {
label: "Cashback",
value: rowData.cashback_perc

},
inputAttributes: {
name: "cashback_perc",
type: "number"
},
className: "col-md-3",
events: {
'change input': 'updateFilter'
},
updateFilter:function(){
console.log('hi');
}

});


LabeledInput is extended from backBone view .
Thanks

Answer

The event listener should be only change not change input, if the input is the root element of the component. If you want "live" updates, use keyup instead of change

Comments