Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

extjs

extjs4

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.

like image 882
Dev Avatar asked May 15 '13 13:05

Dev


2 Answers

you should use change event instead of keyup

like image 194
Naresh Tank Avatar answered Nov 15 '22 09:11

Naresh Tank


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.

like image 35
Alex Tartan Avatar answered Nov 15 '22 09:11

Alex Tartan