Sha256: d16097375ad709033b67230ef13185fa47a52c21bda97ebe515ea38abba1c027
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
Spree.Views.Order.Address = Backbone.View.extend({ initialize: function() { // read initial values from page this.onChange(); this.stateSelect = new Spree.Views.StateSelect({ model: this.model, el: this.$el }); this.render(); this.listenTo(this.model, "change", this.render); }, events: { "change": "onChange", }, onChange: function() { this.model.set(this.getValues()) }, eachField: function(callback){ var view = this; var fields = ["name", "firstname", "lastname", "company", "address1", "address2", "city", "zipcode", "phone", "country_id", "state_name"]; _.each(fields, function(field) { var el = view.$('[name$="[' + field + ']"]'); if (el.length) callback(field, el); }); }, getValues: function() { var attributes = {}; this.eachField(function(name, el) { attributes[name] = el.val(); }); return attributes; }, render: function() { var model = this.model; this.eachField(function(name, el) { el.val(model.get(name)) }); this.stateSelect.render(); } });
Version data entries
3 entries across 3 versions & 1 rubygems