我正在讨论如何通过自定义事件触发stickit onSet 事件。
在下面的代码中,colorChange
事件正确发生并且所有绑定(stickit)事件也正常工作,但onSet
event.
有人能指出错误的地方在哪里吗?
bindings: {
'#color1': {
observe: 'color1',
update : function($el,val){
$el.css("background-color",val);
},
onSet : function(){
//never get fired
},
events : ["colorChange"]
}
}
events : {
"colorChange" : function(){
//the event is occurring
}
}
//somewhere
$("#color1").trigger("colorChange");
<!-- in the html -->
<div id="color1"></div>