I'm using ExtJS 5.1.1
I'm trying to trigger a button click event or simply excute the event handler of this button.
View File:
{xtype: 'button',
itemId: 'searchBtn',
listeners:{
click: 'mainSearch'
}
}
Controller File:
specialKeySearch: function(event){
if (event.getKey() == event.ENTER){
// Trigger 'mainSearch' event handler or click event of button
}
}
mainSearch: function(){
alert("something");
}
I tried so many options, but none of them works. so please point out where the issue is. Below are some I have tried:
1.
document.getElementById('searchBtn').click();
2.
Ext.ComponentQuery.query('#searchBtn')[0].fireEvent('click', Ext.ComponentQuery.query('#searchBtn')[0]);
3.
parent.child('button[itemId=searchBtn]').fireEvent('click', parent.child('button[itemId=searchBtn]'));
Please tell how to trigger a button click event or simply excute the event handler of this button.
Thanks in advanced!