Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    May 2008
    Posts
    6
    Vote Rating
    0
    jherfurth is on a distinguished road

      0  

    Default [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

  2. #2
    Ext User Lukman's Avatar
    Join Date
    Jun 2009
    Location
    Malaysia
    Posts
    138
    Vote Rating
    0
    Lukman is on a distinguished road

      0  

    Default


    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:

    Code:
    gridpanel.addListener('rowdblclick', function(grid, rowindex, e) {
       var record = grid.getStore().getAt(rowindex);
       alert('You dbl-clicked: ' + record.get('title'));
    }, this);
    2) handling title change:

    Code:
    gridpanel.addListener('titlechange', function(grid, newtitle) {
       alert('New title: ' + newtitle);
    }, 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.

  3. #3
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    698
    Vote Rating
    3
    danh2000 is on a distinguished road

      0  

    Default


    Quote Originally Posted by Lukman View Post
    addListener doesn't work like that.
    Yes it does, he said Ext.Element.

    @jherfurth,

    I think you'll have to provide some test code and describe which event you are subscribing to. I've tried it and I get an Ext.Element.

  4. #4
    Ext User Lukman's Avatar
    Join Date
    Jun 2009
    Location
    Malaysia
    Posts
    138
    Vote Rating
    0
    Lukman is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.

  6. #6
    Ext User
    Join Date
    May 2008
    Posts
    6
    Vote Rating
    0
    jherfurth is on a distinguished road

      0  

    Default


    Indeed, I should have scrolled a bit lower... Thanks for the answers anyway!

  7. #7
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,352
    Vote Rating
    127
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Marking this thread as CLOSED.
    Aaron Conran
    @aconran
    Sencha Architect Development Team