Skip to content

Commit

Permalink
Merge pull request jashkenas#2609 from braddunbar/collection-create
Browse files Browse the repository at this point in the history
Fix jashkenas#2606 - Collection#create success arguments.
  • Loading branch information
caseywebdev committed Jun 11, 2013
2 parents 4149557 + fa411d6 commit bfc6d74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@
if (!options.wait) this.add(model, options);
var collection = this;
var success = options.success;
options.success = function(resp) {
options.success = function(model, resp, options) {
if (options.wait) collection.add(model, options);
if (success) success(model, resp, options);
};
Expand Down
11 changes: 11 additions & 0 deletions test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -1142,4 +1142,15 @@ $(document).ready(function() {
equal(collection.length, 2);
});

test("#2606 - Collection#create, success arguments", 1, function() {
var collection = new Backbone.Collection;
collection.url = 'test';
collection.create({}, {
success: function(model, resp, options) {
strictEqual(resp, 'response');
}
});
this.ajaxSettings.success('response');
});

});

0 comments on commit bfc6d74

Please sign in to comment.