var ShippingView = FormView.extend({ el: "#shipping", createAction: sdk.address.add, updateAction: sdk.address.update, events: { }, test_data: { "Name":"name", "Surname":"surname", "Address":"address", "IsDefault":false, "IsBillingDefault":false, "IsOwner":false, "ZipCode":"88040", "City":"City", "Province":"Province", "Phone":"Phone", "Mobile":"Mobile", "Mail":"Mail", "UserId": sdk.auth.user_id, }, 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(){ if (! auth.logged_in()) { return app.router.go("intro") } app.footer.show("SAVE", "CANCEL") document.body.className = "shipping" }, 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 }, })