yeppe yeppe - 6 months ago 3x
Javascript Question

how reset change and destory binding happens in Backbone js

I am an newbie to Backbone.js, can anyone explain what exactly these statements mean, particularly these arguments?

this.model.bind("reset", this.render, this);
this.model.bind("change", this.render, this);
this.model.bind("destroy", this.close, this);


As you can see in the documentation, the signature is:

object.on(event, callback, [context])

Object is any backbone object that emits events, in your case a model.

The first argument is the name of the event which we are listening for.

Second argument is a function to invoke when this event occurs, in your case render of a view.

Third argument is the context i.e the object to which this keyword points to when the callback is executed.