3

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?

0

4 Answers 4

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

Sign up to request clarification or add additional context in comments.

Comments

5

I made the same thing using this:

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

Comments

2

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.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.