web services - can't catch Backbone Collection reset event -


i've stumbled across quite strange

i'm fetching collection, , listening on reset event, somehow event lost

i have minimal example:

$(function() {   var collection = new backbone.collection();   collection.url = 'http://localhost:9000/api/usuario';   collection.on('reset', function() {     console.log('collection reset!');   });   collection.fetch(); }); 

inspecting network can see request seuccessful, , web service returns json data

but there's no way cosole.log('collection reset!') callback executed.

there must silly i'm missing...

from backbone documentation

it uses set (intelligently) merge fetched models, unless pass {reset: true}, 

so guess, using solve problem.

collection.fetch({     reset: true,     success: function() {         //         // called when add, remove , update operations have been done     } }); 

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 -