yeppe yeppe - 2 years ago 56
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);

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download