views:

243

answers:

2

Why doesn't Ext.Container provide a click event? I thought I could simply add a listener to the config passed to the constructor, but click is not a public event for Ext.Container. I understand I can add a click listener to the DIV created by the container, but why does Container not support this?

A: 

Container is an element, so you should (not tested) be able to do an Ext.get(containerVar).addListener('click', function(evtObj, element) { /* do something */});

Jerry
Yes, I can do that, but I am wondering why? Why no click event for the container? Why must I add the listener after the container is rendered?
Upper Stage
+2  A: 

Ext does not provide every possible DOM event on every component. Sometimes DOM events are propagated through a component when it makes sense (like the various click events you can handle for a grid, for example) but usually component events are custom events that are specific to the functionality of the component. The cases where click events are raised through Ext, it is normally integral to the functionality of the component. Container, as a non-visual base class, would not normally be the level of abstraction at which one would expect to handle clicks. But if you must do so, you'll have to go through the underlying DOM node.

bmoeskau
That makes sense. Thanks.
Upper Stage