Search code examples
jquerybackbone.jsbackbone-views

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


Solution

  • 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