PDA

View Full Version : TextField Enter Key After Click External Button



Awersione
19 Apr 2012, 2:14 AM
items:[


{
xtype: 'form',
id: 'myForm',
items: [
{
xtype: 'textfield',
id: 'myTextField',
listeners: {
spacialkey: function(f,e){
if(e.getKey() == e.ENTER){
console.log('I wanna click btnSearch button on here.'); // It's working
// But i wanna click btnSearch button click event
}
}
}
}
],
buttons: [
{
text: 'Search',
id: 'btnSearch',
handlers: function(){
// bla bla
// bla bla
console.log('It's working :)');
}
}
]
}
]

friend
19 Apr 2012, 5:23 AM
The use of hard-coded IDs is a bad practice...

Regardless:



var button = Ext.ComponentQuery.query('#myForm')[0].down('button[text="Search"]');
button.fireEvent('click', button);