#Backbone.slet Get and set attributes of Backbone.js models that won't persist upon save().
##How come? For all the convenience of persisting Backbone models, sometimes an attribute is useful to the client but not the server:
- A model knows the client has hidden it, but the server doesn't need to.
- Multiple clients are sharing the same model (say, Node.js & &yet are helping out) but need their own copy of certain attributes. This might even be a security concern.
##Usage
Create / extend Slet as you would a usual Backbone model. Mind that Slet models have an overwritten save() method to slip out local variables, current to Backbone.js v0.5.3:
var demo = new Slet();
instead of set(obj,[options]):
setLocal(obj,[options]), alias slet(obj,[options])
Set options.silent to true to suppress the change event.
instead of get():
getLocal(), alias glet()
###Example:
var demo = new Slet();
demo.setLocal({'testVal':'hiya'});
demo.save({}, {success: function(model,resp) {
var fromServer = Slet.extend(resp);
var stillClient = model;
fromServer.getLocal('testVal'); //error
stillClient.getLocal('testVal'); //'hiya'
}});
##The local attribute Slet just creates a local attribute (i.e., model.get('local') ), stores your local properties there, and slips the property out during save(). Local doesn't reach sync(), but if sync returns its own 'local' property it will be overwritten. Parse that out if you want:
parse: function(resp) {
if(typeof(resp.local) !== 'undefined') {
delete resp.local;
}
return resp;
}