Skip to content

Instantly share code, notes, and snippets.

@bhelx
Created November 8, 2012 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhelx/4041406 to your computer and use it in GitHub Desktop.
Save bhelx/4041406 to your computer and use it in GitHub Desktop.
hacked Backbone model
/** WTF MAYNE **/
Admin.User = Backbone.Model.extend({
idAttribute: '_id',
setAction: function (action) {
this.action = action;
},
getAction: function () {
if (!this.action) return '';
var action = this.action;
this.action = null;
return '/'+action;
},
url: function () {
return Admin.API + (this.isNew() ? '/users/' : '/users/' + this.get('_id') + this.getAction());
},
parse: function (data) {
if (data.user) return data.user;
return data;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment