Hybrid View
-
18 Jul 2009 3:51 AM #1
[CLOSED] [3.0.0] Event handler arguments receive DOM element instead of Ext.Element
[CLOSED] [3.0.0] Event handler arguments receive DOM element instead of Ext.Element
Hi,
I'm facing the following problem:
In the documentation of Ext.Element.addListener(), the second parameter to the handler function fn(evt, el, obj) should be an Ext.Element.
Instead, the handler receive the HTML element that received the event. In addition, if the HTML element that received the event was a child of the element on which the handler has been set up, that child element is given to the handler, not the element on which the handler has been set up.
I don't know if this is the intended behaviour, but then the documentation should be fixed.... This is rather confusing ;-).
Thanks for the wonderful job!
Julien
-
18 Jul 2009 4:53 AM #2
addListener doesn't work like that. If you call, for example, panel.addListener(eventName, handlerFn, scope), the parameters that handlerFn receives are totally dependent on what eventName is. Let me demonstrate it with a gridpanel:
1) handling row double-clicking:
2) handling title change:Code:gridpanel.addListener('rowdblclick', function(grid, rowindex, e) { var record = grid.getStore().getAt(rowindex); alert('You dbl-clicked: ' + record.get('title')); }, this);
As you can see, the functions parameters, as bolded, are different depending on what the event really is. So, the (evt, el, o) parameter set that is mentioned in the addListener() API documentation is misleading and cannot be used. Instead, you need to refer to the specific event definition to see what kind of parameters your event handler will receive. In the API documentation, you just have to scroll down to the 'Public Events' section; the parameters definitions are there for each event that the component supports.Code:gridpanel.addListener('titlechange', function(grid, newtitle) { alert('New title: ' + newtitle); }, this);
-
18 Jul 2009 5:02 AM #3
-
18 Jul 2009 5:11 AM #4
Fine. Ext.Element that is. But I stand corrected that is if you scroll down to Public Events section in API page for Ext.Element, all the events expect HtmlElement as the 2nd parameters. What I said about refering to event definition instead of what told in addListener() definition is the truth.
-
18 Jul 2009 5:35 AM #5
I changed the Ext 3.0 docs to specify that an HtmlElement is returned, not an Ext.Element.
They will be visible when the docs are released.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
-
18 Jul 2009 6:50 AM #6
Indeed, I should have scrolled a bit lower... Thanks for the answers anyway!
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote