Reputation: 197
I want to call button click in textfield enter function.
items: [
{
xtype: 'form',
id: 'myForm',
items: [
{
xtype: 'textfield',
id: 'myTextField',
listeners: {
specialkey: function(f,e){
if(e.getKey() == e.ENTER){
console.log('Spacial Key = Enter'); // It's working
// But i wanna click btnSearch button click event
}
}
}
}
],
buttons: [
{
text: 'Search',
id: 'btnSearch',
handlers: function(){
// bla bla
// bla bla
// ...
}
}
]
}
]
var myform = Ext.getCmp('myForm');
myForm.getForm().submit()
It's working but btnSubmit.click function not working
Upvotes: 7
Views: 12600
Reputation: 2492
this code working :
{
fieldLabel : 'Password',
name : 'j_password',
inputType : 'password',
allowBlank : false,
listeners : {
'render' : function(cmp) {
cmp.getEl().on('keypress', function(e) {
if (e.getKey() == e.ENTER) {
submitform();
}
});
}
}
}
Upvotes: 2
Reputation: 197
Ext.getCmp('btnSearch').focus();
I Dont Think It But Its Working For Me :)
Thanks For All
Upvotes: 1
Reputation: 136
Depending on you scope you can try this:
Ext.getCmp("btnSearch").handler.call(Ext.getCmp("btnSearch").scope);
Upvotes: 1
Reputation: 17860
It will be easier to create a method like doSearch()
and call this method from both handlers.
Upvotes: 1