Results 1 to 5 of 5

Thread: Difference between el and body

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
      0  

    Default Difference between el and body

    Hi

    I'm trying to understand the difference between binding option of listeners of a panel. Please let m eknow what exactly happens when the el property or body property is bound with the event w.r.t following code:

    listeners: {
    click: {
    element: 'el', //bind to the underlying el property on the panel
    fn: function(){ console.log('click el'); }
    },
    dblclick: {
    element: 'body', //bind to the underlying body property on the panel
    fn: function(){ console.log('dblclick body'); }
    }
    }


    Thanks

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,381
    Answers
    3997
    Vote Rating
    1536
      0  

    Default

    They are different DOM elements. If you create a panel it will have a <div> at the top level of the Panel DOM which is the el. Below it you will have other <div>s for the header and the panel body.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Thank you mitchellsimoens. But I'm still unclear on its usage in a practical scenario. Lets say If I use el and listen to mouseover event and when I mouseover on panel body the function should not be called. Am I right? But this is not happening. Both el and body seems to have same effect. Can you please help me understand its practical relevance.

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585
    Vote Rating
    394
      0  

    Default

    The el is the outermost element for the panel.

    The body is one of the child elements.

    Docked items like the panel's header are not inside the body but they are inside the el.

    Keep in mind that events bubble (propagate) so an event that fires on the panel's body will also fire on the el unless the event's propagation is stopped.

    For a concrete example of a difference, a mouseover listener registered on the body will not fire if you mouseover on the header. A mouseover listener registered on the el will fire for both the body and header.

  5. #5
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,381
    Answers
    3997
    Vote Rating
    1536
      0  

    Default

    Quote Originally Posted by aravindsastry View Post
    Thank you mitchellsimoens. But I'm still unclear on its usage in a practical scenario. Lets say If I use el and listen to mouseover event and when I mouseover on panel body the function should not be called. Am I right? But this is not happening. Both el and body seems to have same effect. Can you please help me understand its practical relevance.
    If you have a mouseover event on the el then when you move your mouse anywhere within the component it will fire. If you have a mouseover event on the body it will only fire on the body but if you mouse over the header (where the title is) it will not fire as the header isn't within the body but is within the el.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •