Skip to content

Instantly share code, notes, and snippets.

@alxarch
Created December 26, 2012 01:36
Show Gist options
  • Save alxarch/4377045 to your computer and use it in GitHub Desktop.
Save alxarch/4377045 to your computer and use it in GitHub Desktop.
// Improved unset for multiple values.
unset: function(attr, options){
var unset = {}, i, max;
if(typeof attr === 'string'){
return Backbone.Model.prototype.unset.call(this, arguments);
}
if(attr instanceof Array){
for(i = 0, max = attr.length; i < max; i++){
unset[attr[i]] = null;
}
return this.set(unset, _.extend({}, options, { unset: true }));
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment