mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
#1412 - Trigger "sync" event for fetch also
This commit is contained in:
@@ -634,4 +634,17 @@ $(document).ready(function() {
|
||||
col.fetch(opts);
|
||||
col.create(m, opts);
|
||||
});
|
||||
|
||||
test('#1412 - Trigger "sync" event for fetch also', 1, function() {
|
||||
var collection = new Backbone.Collection;
|
||||
collection.sync = function(method, model, options) {
|
||||
options.success();
|
||||
};
|
||||
var syncTriggered = false;
|
||||
collection.on('sync', function() {
|
||||
syncTriggered = true;
|
||||
});
|
||||
collection.fetch();
|
||||
ok(syncTriggered);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -831,4 +831,16 @@ $(document).ready(function() {
|
||||
model.destroy(opts);
|
||||
});
|
||||
|
||||
test('#1412 - Trigger "sync" event for fetch also', 1, function() {
|
||||
var model = new Backbone.Model;
|
||||
model.sync = function(method, model, options) {
|
||||
options.success();
|
||||
};
|
||||
var syncTriggered = false;
|
||||
model.on('sync', function() {
|
||||
syncTriggered = true;
|
||||
});
|
||||
model.fetch();
|
||||
ok(syncTriggered);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user