简体   繁体   中英

Backbone Click Event On Button Not Working

https://jsfiddle.net/2j0bw7yy/

If you look at the jsfiddle link above you can see a very basic Backbone app.

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. 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. Backbone requires at least 1.7.x.

In the backbone code, this was failing since 1.6.x does not have .off

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM