Harry
Harry

Reputation: 55009

backbone.js events are not bound after model change?

Here's the code in the view initialize:

  var self = this
  this.model.bind('change', function () {
    self.render();
  });

I have a bunch of events defined:

events: {
  "click #blah": "blah",
},

But after changing the model and re-rendering the view the events are no longer bound?

I can bind them by putting a this.delegateEvents() in the render, but I don't think that's doing it correctly.

Am I doing something wrong?

Upvotes: 2

Views: 431

Answers (1)

donnut
donnut

Reputation: 190

Did you set the el property in your view? The events are delegated to this el.

Upvotes: 0

Related Questions