diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-31 18:32:13 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-31 18:32:13 +0200 |
commit | 9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 (patch) | |
tree | 995539a44a25c54344639d5ade7aa3e48624ed97 /module/web/static/js/models | |
parent | added account page (diff) | |
download | pyload-9ea1ab90b4705ef4d5ce37ded36a214f276c0a18.tar.xz |
add and delete accounts, db will be resetted
Diffstat (limited to 'module/web/static/js/models')
-rw-r--r-- | module/web/static/js/models/Account.js | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/module/web/static/js/models/Account.js b/module/web/static/js/models/Account.js index 55e63ac08..c6e023578 100644 --- a/module/web/static/js/models/Account.js +++ b/module/web/static/js/models/Account.js @@ -1,4 +1,4 @@ -define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backbone, _, Api) { +define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'], function($, Backbone, _, App, Api) { return Backbone.Model.extend({ @@ -22,7 +22,6 @@ define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backb // Model Constructor initialize: function() { - }, // Any time a model attribute is set, this method is called @@ -30,8 +29,21 @@ define(['jquery', 'backbone', 'underscore', 'utils/apitypes'], function($, Backb }, - save: function(options){ - // TODO + save: function(options) { + options = App.apiRequest('updateAccountInfo', {account: this.toJSON()}, options); + return $.ajax(options); + }, + + destroy: function(options) { + options = App.apiRequest('removeAccount', {account: this.toJSON()}, options); + var self = this; + options.success = function() { + self.trigger('destroy', self, self.collection, options); + }; + + // TODO request is not dispatched +// return Backbone.Model.prototype.destroy.call(this, options); + return $.ajax(options); } }); |