Dev
Dev

Reputation: 3932

keyup event not getting fired on setValue() of the textfield

I am using two tabpanels (for e.g T1 and T2). Their are two textfields and submit button in T2 as shown:

xtype: 'form',
title: 'Search',
id:'searchref',                          
items: [
    {
        xtype: 'textfield',
        fieldLabel: 'reference1',
        id:'reference1',     
        enableKeyEvents:true,
        listeners:{
            keyup:function(){
                Ext.getCmp('Submit').enable();
                Ext.getCmp('reference2').disable();
                if(Ext.getCmp('reference1').getValue() == "" )
                {
                    Ext.getCmp('Submit').disable();
                    Ext.getCmp('reference2').enable();
                }                                                       
            }
        }
     },
     {
            xtype: 'textfield',
            fieldLabel: 'reference2',
            id:'reference2',     
            enableKeyEvents:true,
            listeners:{
                keyup:function(){
                    Ext.getCmp('Submit').enable();
                    Ext.getCmp('reference1').disable();
                    if(Ext.getCmp('reference2').getValue() == "" )
                    {
                        Ext.getCmp('Submit').disable();
                        Ext.getCmp('reference1').enable();
                    }                                                       
                }
            }
      },

    {
        xtype: 'button',
        text: 'Submit',
        disabled:true,  
        id:'Submit',                            
    }   
]

In my T1, I am trying to do as shown:

Ext.getCmp('tabpanel').setActiveTab(1);
Ext.getCmp('reference1').setValue(RefNo);

MY PROBLEM:

The keyup event listener not getting fired on setting the value of textfield from T1

Please help me resolve this.
Any help is appreciated. Thanks.

Upvotes: 6

Views: 5194

Answers (2)

Alex Tartan
Alex Tartan

Reputation: 6826

I'm posting this for historical reasons. Maybe it will come in handy for developers working on legacy Extjs3 (I'm still writing code for Extjs 3.4).

To enable keyup and keypress events on textfiels, add enableKeyEvents

xtype:           'textfield',
enableKeyEvents: true,

By default:

keypress( this, e )
Keypress input field event. This event only fires if enableKeyEvents is set to true.

and

keyup( this, e )
Keyup input field event. This event only fires if enableKeyEvents is set to true.

Upvotes: 3

Naresh Tank
Naresh Tank

Reputation: 1568

you should use change event instead of keyup

Upvotes: 4

Related Questions