Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@
// `set(attr).save(null, opts)` with validation. Otherwise, check if
// the model will be valid when the attributes, if any, are set.
if (attrs && !wait) {
if (!this.set(attrs, options)) return false;
if (!this.set(attrs, options)) return Backbone.notValidated(this);
} else {
if (!this._validate(attrs, options)) return false;
if (!this._validate(attrs, options)) return Backbone.notValidated(this);
}

// Set temporary attributes if `{wait: true}`.
Expand Down Expand Up @@ -646,7 +646,7 @@

if (this.isNew()) {
options.success();
return false;
return Backbone.newDestroyed(this);
}
wrapError(this, options);

Expand Down Expand Up @@ -1366,7 +1366,19 @@
model.trigger('request', model, xhr, options);
return xhr;
};

// Override Backbone.newDestroyed to match with Backbone.sync
// for example to return Promise.resolve(model)
Backbone.newDestroyed = function(model) {
return false;
}

// Override Backbone.notValidated to match with Backbone.sync
// for example to return Promise.reject(model.validationError)
Backbone.notValidated = function(model) {
return false;
}

// Map from CRUD to HTTP for our default `Backbone.sync` implementation.
var methodMap = {
'create': 'POST',
Expand Down