ExtJS4 - Ext.dom.Element and fireEvent

I am testing ExtJS4, but I need help here ...

I have this HTML code:

<input type="button" value="Click" id="sendButton"> <input type="text" id="tbox"> 

And this script code:

 Ext.addBehaviors({ '# sendButton@click ': function (){ alert("Test"); } }); Ext.get('tbox').on('keydown', function(e){ if(e.keyCode == Ext.EventObject.ENTER){ //Ext.select('#sendButton').fireEvent('click'); //Ext.get('sendButton').fireEvent('click'); // this is what I need working.... } }); 

I just want when you press enter in the text box, it will act just like you clicked a button.

Can anyone help?

+6
source share
1 answer
 Ext.get('tbox').on('keydown', function(e){ if(e.keyCode == Ext.EventObject.ENTER){ Ext.get('sendButton').dom.click(); } }); 

Although I would advise wrapping the above code with Ext.onReady(function(){...})

+4
source

Source: https://habr.com/ru/post/924922/


All Articles