From 9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 31 Mar 2013 18:32:13 +0200 Subject: add and delete accounts, db will be resetted --- module/web/static/js/models/Account.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'module/web/static/js/models') 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); } }); -- cgit v1.2.3