Sha256: 71b0844e2f029fa518886ab041ce3f5304c04e2beaecbbf3a179bffbe0c19d8d

Contents?: true

Size: 893 Bytes

Versions: 7

Compression:

Stored size: 893 Bytes

Contents

Spree.Views.EditSubscriptionPayment = Backbone.View.extend({
  initialize: function() {
    this.onSelectMethod()
  },

  events: {
    'change [name="subscription[payment_method_id]"]': 'onSelectMethod',
  },

  onSelectMethod: function(e) {
    this.selectedId = parseInt(this.$('select[name="subscription[payment_method_id]"]').val())
    this.render()
  },

  render: function() {
    let selectedId = this.selectedId

    this.$('select[name="subscription[payment_source_id]"] option').each(function () {
      if (!$(this).data('js-payment-method-id') || parseInt($(this).data('js-payment-method-id')) === selectedId) {
        $(this).prop('disabled', false)
      } else {
        $(this).prop('disabled', true)
      }
    })
  },
});

Spree.ready(function() {
  $(".js-edit-subscription-payment").each(function() {
    new Spree.Views.EditSubscriptionPayment({ el: this })
  });
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
solidus_subscriptions-2.0.2 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-2.0.1 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-2.0.0 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-1.1.0 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-1.0.1 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-1.0.0 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js
solidus_subscriptions-1.0.0.rc1 app/assets/javascripts/spree/backend/solidus_subscriptions/edit_subscription_payment.js