Created
November 8, 2012 20:34
-
-
Save bhelx/4041406 to your computer and use it in GitHub Desktop.
hacked Backbone model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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