Sha256: 2156d6bbbee36eff635fcaa3ba24bd8566c4a9f3485f117296d68db33849203c
Contents?: true
Size: 1.05 KB
Versions: 59
Compression:
Stored size: 1.05 KB
Contents
Spree.Views.Order.Address = Backbone.View.extend({ initialize: function(options) { // read initial values from page this.onChange(); this.render(); this.listenTo(this.model, "change", this.render); this.stateSelect = new Spree.Views.StateSelect({ model: this.model, el: this.$el }); }, events: { "change": "onChange", }, onChange: function() { this.model.set(this.getValues()) }, eachField: function(callback){ var view = this; var fields = ["firstname", "lastname", "company", "address1", "address2", "city", "zipcode", "phone", "country_id"]; _.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)) }) } });
Version data entries
59 entries across 59 versions & 2 rubygems