Search code examples
javascriptextjsclickpanel

ExtJS4, how to get the only "last" panel when click on nested panels?


Using ExtJS 4.2 and nested panels, when I click on a panel I need to get this only panel.
But I currently get this panel AND its parents panels.

Here's the FIDDLE.
When you click on "A > B > C", the function must be called only one time, with "A > B > C" panel as parameter.
When you click on "A > B", the function must be called only one time, with "A > B" panel as parameter.
etc.

I'm not supposed to know that top level panel is the top level panel.
There is not only once click, the code have to work with multiple clicks on any panels.


Solution

  • You need to apply click event with event param and stop it just after calling myFonction.

    Code snippet:

    panel.on('click', function (event) {
        myFonction(panel);
        event.stopEvent();
        event.stopPropagation();
        return false;
    }, this, {
        element: 'el'
    });
    

    Working Fiddle

    Hope this will help/guide you.