Change event on select with knockout binding, how can I know if it is a real change?

前端 未结 11 1987
独厮守ぢ
独厮守ぢ 2021-01-30 08:05

I am building a permissions UI, I have a list of permissions with a select list next to each permission. The permissions are represented by an observable array of objects which

11条回答
  •  自闭症患者
    2021-01-30 08:27

    Create js component

    define([
        'Magento_Ui/js/form/element/select',
        'mage/translate'
    ], function (AbstractField, $t) {
        'use strict';
    
        return AbstractField.extend({
            defaults: {
                imports: {
                    update: 'checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset.country_id:value'
                },
                modules: {
                    vat_id: '${ $.parentName }.vat_id'
    
    
                }
            },
    
            /**
             * Initializes UISelect component.
             *
             * @returns {UISelect} Chainable.
             */
            initialize: function () {
                this._super();
                this.vat_id().visible(false);
                return this;
            },
            update: function (value) {
                if(value == 'GB'){
                    this.vat_id().visible(true);
                }else{
                    this.vat_id().visible(false);
    
                }
            }
            
            
                
             
          
        });
    });
    

提交回复
热议问题