2015-03-31 83 views
0

https://jsfiddle.net/2j0bw7yy/骨干Click事件在按钮无效

如果你看的jsfiddle链接上面你可以看到一个非常基本的主干应用程序。

一切正常,除了这行:

events: { 
    "click button": "updatePoints" 
}, 

updatePoints: function() { 
    alert("aaa"); 
    return this; 
}, 

当我点击该按钮,updatePoints函数没有被调用。什么都没发生。

在控制台中的错误信息是相当神秘:

Uncaught TypeError: undefined is not a function 
+0

不使用精缩版。 – 2015-03-31 12:13:01

回答

1

您正在使用jQuery 1.6.x上骨干至少需要1.7.x.

在骨干代码,这是失败的,因为1.6.x的没有.off

undelegateEvents: function() { 
    this.$el.off('.delegateEvents' + this.cid); 
    return this; 
}, 

https://jsfiddle.net/2j0bw7yy/1/