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...
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
Post a Comment