Difference between bind and on in backbone

backbone.js, bind, event-binding, javascript, underscore.js

Solution

this.bind('myEvent', this.render, this);
this.on('myEvent', this.render, this);

These are exactly equivalent and are not related to the underscore `bind` function.

Here is some code from Backbone source:

// Aliases for backwards compatibility.
Events.bind   = Events.on;
Events.unbind = Events.off;

So, in both lines of your code, you are calling the same function.

Problem

What is the difference between bind() and on() methods in Backbone.js Documentation for on() : On method documentation at backbone.js Documentation for bind() : Bind method documentation at underscore.js Which of the two should be used to bind custom events for objects ? Usage example: ``` this.bind('myEvent', this.render, this); this.on('myEvent', this.render, this); ```

Original source