I have a collection where is has an event that gets fired when a model is added. I have read in the docs where it should have an options parameter but not able to get to it. I basically want to find the index the model is at in the collection. Inside my collection I have this.
initialize: function( ) {
this.bind( 'add', this.onModelAddedd, this );
},
onModelAddedd: function( model, options ){
console.log("options = ", options);
}
The documentation is a little unclear on this so your confusion is understandable. From the fine manual:
So the second argument to the
add
handler is the collection itself. The ubiquitousoptions
that you're looking for is always the last argument so you want this:Demo (open your console please): http://jsfiddle.net/ambiguous/Das2t/
The final
options
argument is implied to be the last argument throughout the documentation but it isn't explicitly spelled out anywhere.