The Backbone.Events object comes equipped with seven methods that allow you to invoke a specific function when an event occurs, trigger an event, or stop waiting for an event to occur. We will go over the signature and purpose of each method along with an example of when it's most appropriately used.

on(name, callback[, context])

The on method is used to bind a callback to an event. In other words, you're saying you want a function (callback, with an optional context) to be invoked when (on) an event (name) is triggered. on is best used when you want the context of your callback to be the object triggering the event.

Here are the arguments for on:

  • name - The name of the event to listen to.
  • callback - The function to invoke when the name ...

Get Developing a Backbone.js Edge now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.