Enhancing Model with isEmpty function

This commit is contained in:
Andrew Ivaskevych
2014-09-09 16:47:52 +03:00
parent 1dbe3ddf2f
commit e6fa0e2aaa

View File

@@ -578,6 +578,11 @@
return this._validate({}, _.extend(options || {}, { validate: true }));
},
// Check if the model is empty.
isEmpty: function() {
return _.isEmpty(this.attributes);
},
// Run validation against the next complete set of model attributes,
// returning `true` if all is well. Otherwise, fire an `"invalid"` event.
_validate: function(attrs, options) {