Prince of Sweet heart
Prince of Sweet heart

Reputation: 57

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.

Upvotes: 1

Views: 708

Answers (1)

Mohit Saxena
Mohit Saxena

Reputation: 1449

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;
        }
    });

Upvotes: 2

Related Questions