Just a bit of trivia;
I’m creating views and models in a loop then trying to bind custom events to them. All goo so far but what about when I want to find out with object fired the event. I know there are other longer winded ways to individually assign events to each one in series but I guess I’m looking for a more efficient way:
initialize: function(args)
{
this.views = [];
this.models = [];
for(var i =0;i<args.items.length;i++)
{
this.models[i] = new BasicContentModel({url:args.items[i].urlRoot+args.items[i].url});
this.views[i] = new BasicContentView({model:this.models[i],id:i,className:"tab-"+i});
this.views[i].bind("updated",this.update,this) //<-- heres the bind
}
// blah blah
},
update: function(args)
{
console.log("updating:",args) //<-- trying to get which one called the update
}
Does this make sense? basically I want to log which view just got updated (bubbling upward sort of thing)
Sorry, I dont think I can delete my question due to lack of points but I’ve just found the answer elsewhere and thought maybe someone else in future might find this useful:
When you trigger the event the object should be included as the 2nd parameter to the trigger method like so
From BasicContentView