Backbone 按钮上的单击事件不起作用
Backbone Click Event On Button Not Working
https://jsfiddle.net/2j0bw7yy/
如果您查看上面的 jsfiddle link,您会看到一个非常基本的 Backbone 应用程序。
除此行外一切正常:
events: {
"click button": "updatePoints"
},
updatePoints: function() {
alert("aaa");
return this;
},
当我点击按钮时,updatePoints 函数没有被调用。没有任何反应。
控制台中的错误消息非常隐晦:
Uncaught TypeError: undefined is not a function
您正在使用 jQuery1.6.x。 Backbone 至少需要 1.7.x.
在 backbone 代码中,这是失败的,因为 1.6.x 没有 .off
undelegateEvents: function() {
this.$el.off('.delegateEvents' + this.cid);
return this;
},
https://jsfiddle.net/2j0bw7yy/
如果您查看上面的 jsfiddle link,您会看到一个非常基本的 Backbone 应用程序。
除此行外一切正常:
events: {
"click button": "updatePoints"
},
updatePoints: function() {
alert("aaa");
return this;
},
当我点击按钮时,updatePoints 函数没有被调用。没有任何反应。
控制台中的错误消息非常隐晦:
Uncaught TypeError: undefined is not a function
您正在使用 jQuery1.6.x。 Backbone 至少需要 1.7.x.
在 backbone 代码中,这是失败的,因为 1.6.x 没有 .off
undelegateEvents: function() {
this.$el.off('.delegateEvents' + this.cid);
return this;
},