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

Version Path
solidus_backend-2.9.6 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.8.6 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.5 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.4 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.6.6 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.7.4 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.8.5 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.3 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.2 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.10.0.beta1 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.7.3 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.6.5 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.5.2 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.1 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.0 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.9.0.rc.1 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.8.4 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.8.3 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.7.2 app/assets/javascripts/spree/backend/views/order/address.js
solidus_backend-2.6.4 app/assets/javascripts/spree/backend/views/order/address.js