Hybrid View
-
11 Dec 2007 5:12 AM #1
Cannot fire click event on Ext.Button
Cannot fire click event on Ext.Button
I am trying to fire a click event on a button whose handler was given in the config object.
This is the code. My goal is to have the handler of the second button called in response of a click on the first button. But it does not work.
ThanksCode:<div id='fire-btn'></div> <div id='event-btn'></div> Ext.onReady(function(){ fireBtn = new Ext.Button({ renderTo: 'fire-btn', text: 'Fire click event', handler: function(){ eventBtn.fireEvent('click'); } }); eventBtn = new Ext.Button({ renderTo: 'event-btn', text: 'Event Btn', handler: function(){ alert('ok'); } }); });
Luca
-
11 Dec 2007 6:07 AM #2
Define "var eventBtn = ..."
Make everything as simple as possible, but not simpler.
- Albert Einstein
-
11 Dec 2007 7:47 AM #3
-
11 Dec 2007 8:27 AM #4
You are right. This works.
Code:listeners: {click: function() {alert("yep")}},Make everything as simple as possible, but not simpler.
- Albert Einstein
-
11 Dec 2007 8:37 AM #5
-
11 Dec 2007 9:23 AM #6
Not sure what you think the problem is - the following code works.
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Hello World Window Example</title> <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" /> <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script> <script type="text/javascript" src="../../ext-all.js"></script> <script text="text/javascript"> Ext.onReady(function(){ var button = new Ext.Button({ renderTo:'test', text:'Hello', handler: function() { alert('hello'); } }); }); </script> </head> <body> <div id="test"></div> </body> </html>Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide


Reply With Quote