最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - programmatically click a button in Extjs - Stack Overflow

programmeradmin3浏览0评论

I use the MVC-architecture in Extjs application. I have a simply button, it looks like a:

{
  xtype: 'button',
  id: 'searchButton',
  margin: '5 0',
  text: 'Search'
}

And how I can press it button programmatically from this view?

I use the MVC-architecture in Extjs application. I have a simply button, it looks like a:

{
  xtype: 'button',
  id: 'searchButton',
  margin: '5 0',
  text: 'Search'
}

And how I can press it button programmatically from this view?

Share Improve this question edited Jan 15, 2014 at 10:11 user3197236 asked Jan 15, 2014 at 8:24 user3197236user3197236 331 silver badge4 bronze badges 0
Add a ment  | 

4 Answers 4

Reset to default 6

I think imitate button-click from view it is a not good solution. If you use a MVC-architecture you may do it from Controller. And you may fire events, because your solution is bad way. But if you still want do it, this code I think will be helpful for you:

Ext.get('searchButton').dom.click();

And please read this article in official site EXTjs MVC-architecture

I made the same thing using this:

 var ele = Ext.getCmp("searchButton");
 ele.fireEvent('click');

For ExtJs 3.0 / 3.4 you can use

Ext.getCmp("searchButton").el.dom.click()

.el.dom return the actual HTML object for every ExtJs object... so once you reach el.dom now you are doing normal JavaScript... this applies nearly to all ExtJs elements.

in controller get the reference for the element just and call click() :

var me = this;

var refs = me.getReferences();
var save = refs.save_button;
save.click();
发布评论

评论列表(0)

  1. 暂无评论