Skip to content
Browse files

Merge pull request #1114 from braddunbar/save-wait-validate

Fix #1057 - Save with wait validates model.
  • Loading branch information...
2 parents 315d67b + 6948b59 commit e2e0a0982b6478af7f98000d97b2b146e663d194 @jashkenas jashkenas committed Mar 19, 2012
Showing with 10 additions and 1 deletion.
  1. +4 −1 backbone.js
  2. +6 −0 test/model.js
View
5 backbone.js
@@ -337,7 +337,10 @@
}
options = options ? _.clone(options) : {};
- if (options.wait) current = _.clone(this.attributes);
+ if (options.wait) {
+ if (!this._validate(attrs, options)) return false;
+ current = _.clone(this.attributes);
+ }
var silentOptions = _.extend({}, options, {silent: true});
if (attrs && !this.set(attrs, options.wait ? silentOptions : options)) {
return false;
View
6 test/model.js
@@ -615,6 +615,12 @@ $(document).ready(function() {
equal(changed, 1);
});
+ test("save with wait validates attributes", 1, function() {
+ var model = new Backbone.Model();
+ model.validate = function() { ok(true); };
+ model.save({x: 1}, {wait: true});
+ });
+
test("nested `set` during `'change:attr'`", function() {
var events = [];
var model = new Backbone.Model();

0 comments on commit e2e0a09

Please sign in to comment.
Something went wrong with that request. Please try again.