0

I want to know on click of a view, which ExtJS control was clicked. Do i need to subscribe to click on all the controls or is there a way I can subscribe to the root element and get actual ExtJS control clicked? I am able to find DOM elements but what i want is ExtJS control. I am using latest version ExtJs 5 and i want to listen to click on any element of a view which could be a Panel, Grid, Textarea etc. I am using a single event handler at the top level dom element. My code looks like follows:

    listeners: {
        click: {
            element: "el",
            fn: function fn(e,t) {
                var domComp = Ext.get(t);
                var xComp;
                var currentNode = t;
                while(true) {
                     var compID = currentNode.parentNode.id;
                     xComp = Ext.ComponentManager.get(compID);
                     if(xComp) break;
                     currentNode = currentNode.parentNode;
                }
                //Do something on xComp
           }
       }
   }

I have been partially able to achieve this. But still the problem that I have is that I don't want the click handler for the actual control to be invoked? Just the handler I have written above should be invoked. For ex: if a checkbox is clicked, i don't want it to get checked but instead my above handler is invoked and i know that this checkbox was clicked? Any suggestions?

3
  • Sorry for posting duplicate. This link seems to work for me as of now. (stackoverflow.com/questions/3203872/ext-js-on-click-event) Commented Jul 28, 2014 at 7:41
  • Oops I think I was wrong. As per the documentation, it says Ext.get returns Dom element and not Ext Component. I need to find Ext Component. Any help please? Commented Jul 28, 2014 at 11:23
  • Which Ext version and what exactly is "control" to listen clicks on? Commented Jul 29, 2014 at 6:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.