Search code examples
javascriptbackbone.jsadditionbackbone-events

"add" event in backbone.js


I want to use "add" built-in event in Backbone.js but I don't know how to use and what to put in 3rd parameter of add (option), Can you help me?

as you know we use "add" like this -> "add" (model, collection, options) — when a model is added to a collection. my question is around option! the second question is what does it mean to use "this" instead of (option) ?


Solution

  • You should try to understand how keyword this works in javascript. Wen I use one of available Backbone events, I put this as a third parameter:

    this.model.on('change', this.render, this);