javascript - knockoutjs: custom binding fired multiple times and on the wrong binding -


i have question regarding custom bindings.

here fiddle

there can see have 4 custom bindings...everyone binded same boolean every binding gets fired differently.

is bug?

this great post says is fixed in 3.x ... i'm using 3.1.0 , seems not fixed.

my concrete problem is: want custom binding, gets fired if model changes , not if binding changes. (binding 4 in fiddle)

ko.bindinghandlers.customfour = {     update: function(element, valueaccessor, allbindingsaccessor) {         var value = valueaccessor();         var allbindings = allbindingsaccessor();         console.log('customfour: why called on value change? not value binding');         console.log(value());         console.log(allbindings.value());     } }; 

just @ fiddle , run it...it says everthing ;)

<input data-bind="value: test, valueupdate: 'afterkeydown', customfour: test2" /> <input type="checkbox" data-bind="checked: test2" /> 

can explain behavior me? thx!

i guess calling allbindingsaccessor() evaluate bindings , cause update called on each change later on.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -