我正在编写一个小部件,它的表单元素附带了一个单击事件。我使用jQuery绑定它。
但是,单击save
, 绑定丢失。也就是说,单击这些元素不会再触发该函数。
我试着用on()
jQuery方法,如建议的here, 但这无助于:
var buttonsHolder=jQuery(\'#widgets-right .icon_buttons\');
// save the array of big icons, for later reference, and assign them the click event
var buttons=buttonsHolder.children(\'input\');
buttons.on("click",function(){
openPanel(jQuery(this),jQuery(this).index());
});
我可以把我的js
小部件表单中的代码,如建议的here. 这确实解决了问题,但我真的更愿意js
代码分隔。即使在save
是否单击按钮?