Skip to content

Commit

Permalink
Merge pull request #4284 from olhapi/master with added test
Browse files Browse the repository at this point in the history
  • Loading branch information
jgonggrijp committed Jan 23, 2024
2 parents e6d434e + d981caa commit 0f9956b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@
var success = options.success;
options.success = function(m, resp, callbackOpts) {
if (wait) {
m.off('error', this._forwardPristineError, this);
m.off('error', collection._forwardPristineError, collection);
collection.add(m, callbackOpts);
}
if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
Expand Down
10 changes: 10 additions & 0 deletions test/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,16 @@
this.ajaxSettings.success();
});

QUnit.test('successful create with wait:true drops special error listener (#4284)', function(assert) {
assert.expect(1);
var collection = new Backbone.Collection;
collection.url = '/test';
collection.on('error', function() { assert.ok(true); });
var model = collection.create({id: '1'}, {wait: true});
this.ajaxSettings.success();
model.trigger('error');
});

QUnit.test('failing create pre-existing with wait:true triggers once (#4262)', function(assert) {
assert.expect(1);
var model = new Backbone.Model;
Expand Down

0 comments on commit 0f9956b

Please sign in to comment.