javascript - Binding Reset In Backbone.js -
i'm trying simple collection in backbone.js, don't understand why callback function (specified in bind) isn't being called. understand documentation, when fetch(), reset event should triggered. suggestions? (code below).
customer = backbone.model.extend( ); customerlist = backbone.collection.extend({ model : customer, url : "test.php", }); var chartview = backbone.view.extend({ el: $('body'), initialize: function(){ _.bindall(this, 'render'); this.collection.bind("reset", self.render); this.collection.fetch( ); }, render : function() { console.log("render"); } }); var chartview = new chartview( { collection: new customerlist()} ); })(jquery);
if using backbone 1.0.0 should passing reset:true reset. else set models collection erstwhile update
this.collection.fetch({reset:true}); ensure response url valid json. reset event fired on success.
Comments
Post a Comment