javascript - Passing an event to a collection in backbone -


i trying trigger behaviour on collection triggering event elsewhere in app. pretty new backbone, have syntax wrong, seems should work

fiddle

var test = backbone.model.extend({ }); var tests = backbone.collection.extend({         model: test,         events: {             "testevent":"testresponce"         },         testresponce: function(){             alert('hello world');         }     });    var mytest = new test();  mytest.trigger('testevent'); 

can done? going wrong?

if want call particular method of collection using testevent event can take path also. working demo

var test = backbone.model.extend({     initialize: function() {         this.on('testevent', function() {             console.log(this.collection);             this.collection.testresponce();         });     } }); var tests = backbone.collection.extend({         model: test,         testresponce: function(){             alert('hello world');         }     });  var mytest = new test(); var testlist = new tests([mytest]); mytest.trigger('testevent'); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -