Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is viewInstance.undelegateEvents() the same as $(this.el).unbind()?

Is viewInstance.undelegateEvents() the same as jQuery's $(this.el).unbind()?

Do they function the same way, as in removing the events from the view?

like image 552
Jan Carlo Viray Avatar asked Jan 20 '26 07:01

Jan Carlo Viray


1 Answers

From http://backbonejs.org/docs/backbone.html#section-131

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

So, they are nearly identical. But the undelegateEvents method scopes the undelegation to the events that the backbone view had explicitly set up with the delegateEvents method, using the declarative events configuration on the view.

like image 84
Derick Bailey Avatar answered Jan 21 '26 20:01

Derick Bailey