diff options
Diffstat (limited to 'StoneIsland/www/js/lib/account/ShippingView.js')
| -rw-r--r-- | StoneIsland/www/js/lib/account/ShippingView.js | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/StoneIsland/www/js/lib/account/ShippingView.js b/StoneIsland/www/js/lib/account/ShippingView.js index 65a55fdc..e2426d2e 100644 --- a/StoneIsland/www/js/lib/account/ShippingView.js +++ b/StoneIsland/www/js/lib/account/ShippingView.js @@ -2,6 +2,9 @@ var ShippingView = FormView.extend({ el: "#shipping", + createAction: sdk.address.add, + updateAction: sdk.address.update, + events: { }, @@ -24,8 +27,10 @@ var ShippingView = FormView.extend({ initialize: function(){ this.$form = this.$("form") this.$msg = this.$(".msg") + this.$isDefault = this.$("[name=IsDefault]") this.address = new AddressView ({ parent: this }) this.scroller = new IScroll('#shipping', app.iscroll_options) + this.preload() }, show: function(){ @@ -34,7 +39,25 @@ var ShippingView = FormView.extend({ document.body.className = "shipping" }, - finalize: function(){ + finalize: function(data){ + if (this.address.data && this.address.data.Id) { + sdk.address.destroy({ + id: this.address.data.Id, + success: function(){ console.log("destroyed") }, + error: function(){ console.log("destroyed") }, + }) + this.action = this.updateAction + } + else { + this.action = this.createAction + } + data.IsDefault = data.IsDefault ? "true" : "false" + data.Address = data.Address1 + "\n" + data.Address2 + delete data.Address1 + delete data.Address2 + console.log(data) + return + return data }, })
\ No newline at end of file |
