summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/models
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-31 18:32:13 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-31 18:32:13 +0200
commit9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 (patch)
tree995539a44a25c54344639d5ade7aa3e48624ed97 /module/web/static/js/models
parentadded account page (diff)
downloadpyload-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.js20
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);
}
});