-
6 Jun 2008 2:54 AM #1
[Solved] Programmatically click an Ext.Button ??
[Solved] Programmatically click an Ext.Button ??
How can I simulate a click on an Ext.Button, that is, code the click on the button when some event occurs instead of a user actually clicking it. How can this be possible if our target button is hidden ??
Odili Charles Opute
Proudly Nigerian
Blog
Cotributions
Ext.ux.Image
Ext.ux.Wizard
Ext.plugin.ModalNotice
Ext.plugin.ComboLoader
Ext.ux.form.ScreenshotField
-
6 Jun 2008 6:15 AM #2
Any suggestions on this yet ?? I have a Ext.Button but for some reason it's got to be hidden, so the user won't see it to click on it, I've got to script the click on it when the user interacts with something they can see. It's urgent please.Thanks
Odili Charles Opute
Proudly Nigerian
Blog
Cotributions
Ext.ux.Image
Ext.ux.Wizard
Ext.plugin.ModalNotice
Ext.plugin.ComboLoader
Ext.ux.form.ScreenshotField
-
6 Jun 2008 6:28 AM #3
myButton.handler.call(myButton.scope, myButton, Ext.EventObject())
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
6 Jun 2008 7:15 AM #4
firebug says Ext.EventObject() is not a function


I am actually using the browse button extension, it's constructor is thus
So I am applying your suggestion thus:Code:initComponent: function(){ Ext.ux.form.BrowseButton.superclass.initComponent.call(this); // Store references to the original handler and scope before nulling them. // This is done so that this class can control when the handler is called. // There are some cases where the hidden file input browse button doesn't completely cover the Ext.Button. // The handler shouldn't be called in these cases. // It should only be called if a new file is selected on the file system. this.originalHandler = this.handler; this.originalScope = this.scope; this.handler = null; this.scope = null; }
Code:this.browseBtn.originalHandler.call(this.browseBtn.originalScope, this.browseBtn, Ext.EventObject());
Odili Charles Opute
Proudly Nigerian
Blog
Cotributions
Ext.ux.Image
Ext.ux.Wizard
Ext.plugin.ModalNotice
Ext.plugin.ComboLoader
Ext.ux.form.ScreenshotField
-
6 Jun 2008 7:56 AM #5
This is the handler where I want to do the 'click', and this is what I have now:
The onBoxClick function is attached to the click event of an Ext.Element object, I want to click the browse button when the Ext.Element object is clicked. The code in the previous post gives an error, this one just does nothing, what am I missing pleaseCode:onBoxClick: function(evt, el){ //myButton.handler.call(myButton.scope, myButton, Ext.EventObject()) this.browseBtn.originalHandler.call(this.browseBtn.originalScope, this.browseBtn, evt); }
Odili Charles Opute
Proudly Nigerian
Blog
Cotributions
Ext.ux.Image
Ext.ux.Wizard
Ext.plugin.ModalNotice
Ext.plugin.ComboLoader
Ext.ux.form.ScreenshotField
-
6 Jun 2008 8:12 AM #6
Maybe you can just disable the button and then on the click event you just have to enable it...?
-
6 Jun 2008 8:17 AM #7
I have successfully simulated click's in the past using the plain old school dom function "click()". Try grabbing your components Dom, then browse it for that function.
I love ext.
-
7 Jun 2008 7:53 AM #8
Post #5 is actually correct, my error is from some where else
. This proves how to pro grammatically click a Ext.ButtonOdili Charles Opute
Proudly Nigerian
Blog
Cotributions
Ext.ux.Image
Ext.ux.Wizard
Ext.plugin.ModalNotice
Ext.plugin.ComboLoader
Ext.ux.form.ScreenshotField
-
26 Oct 2008 9:12 PM #9
the little correction
the little correction
Animal's solution did a trick for me
but
notCode:myButton.handler.call(myButton.scope, myButton, Ext.EventObject)
Code:myButton.handler.call(myButton.scope, myButton, Ext.EventObject())
-
8 Mar 2011 11:22 AM #10
This worked for me
This worked for me
I found 2 ways:
1)Create the event code in a function and call the function from both sides: btn.on("clic", ...) and from the code you want to simulate the click.
2)Use: btnView.btnEl.dom.click();
See you



Reply With Quote