javascriptsencha-touchsencha-touch-2sencha-touch-2.1

Change event didn't work for selectfield?


i am getting struck with sencha touch select field change event. Usual change event is working fine. but in case option values like this,

{
     xtype: 'selectfield',
     label: 'Choose one',
     options: [{text: 'First Option',  value: 1},
               {text: 'First Option', value: 2},
               {text: 'Third Option',  value: 3}],
     listeners : {
          change : function (selectField, newValue, oldValue)
          {
               console.log(newValue);
          }
     }
}

When this case values are different but display values are same, change event didn't work. Please help to finish this issue.


Solution

  • This is issue with Sencha. you can check this link

    https://www.sencha.com/forum/showthread.php?304198-Select-field-not-firing-change-event-on-same-text-but-different-value.

    But If You have a need to do this then you can do with this way, write this in launch function.

    Ext.override(Ext.field.Input, {
            setValue: function (newValue) {
                var oldValue = this._value;
    
                this.updateValue(this.applyValue(newValue));
    
                newValue = this.getValue();
                this.onChange(this, newValue, oldValue);
    
                return this;
            }
        });