javascript - Knockout change the click event -


i'm trying find way change click event on elements. want think how ko binds click event attached element , changing function has no effect.

viewmodel.clickevent = function(item){    logic }  viewmodel.clickevent = newfunction;  <div data-bind="click: clickeevent">mybutton</div> 

i think need use delegates having hard time figuring out how this. post basic example of how knockout?

if have understood right. create fake event handler can modify without modifying actual event handler binded view.

var viewmodel = {     clickevent : function(item){         if(this.changableclickevent)             this.changableclickevent(item);     },     changableclickevent : null }  viewmodel.changableclickevent = function(){     // logic     alert('logic'); }  ko.applybindings(viewmodel); 

see fiddle


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -