[英]Backbone Click Event On Button Not Working
https://jsfiddle.net/2j0bw7yy/ https://jsfiddle.net/2j0bw7yy/
If you look at the jsfiddle link above you can see a very basic Backbone app. 如果您查看上面的jsfiddle链接,您会看到一个非常基本的Backbone应用程序。
Everything works except this line: 除此行外,一切正常:
events: {
"click button": "updatePoints"
},
updatePoints: function() {
alert("aaa");
return this;
},
When I click the button, the updatePoints function is not called. 当我单击按钮时,不会调用updatePoints函数。 Nothing happens.
什么都没发生。
The error message in the console is quite cryptic: 控制台中的错误消息非常隐晦:
Uncaught TypeError: undefined is not a function
You are using jQuery 1.6.x. 您正在使用jQuery1.6.x。 Backbone requires at least 1.7.x.
骨干网至少需要1.7.x。
In the backbone code, this was failing since 1.6.x does not have .off
在主干代码中,此操作失败,因为1.6.x没有
.off
undelegateEvents: function() {
this.$el.off('.delegateEvents' + this.cid);
return this;
},
https://jsfiddle.net/2j0bw7yy/1/ https://jsfiddle.net/2j0bw7yy/1/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.