-
Extjs Core cuestion
Hi! I need to add the click event for each element of the CompositeElement and toggle its own class.
Code:
arr = Ext.select('.cMenuParentCollapsed');
arr.each(function(){
this.on("click",function(e,t){
this.toggleClass("cMenuParentExpanded");
});
});
when i do this, i can click on any item but it will only toggle the last item :S
What i'm i doing wrong?
Thanx!
-
FIXED
Got it working :S
Code:
arr = Ext.select('.cMenuParentCollapsed');
arr.each(function(){
this.on("click",function(evnt,html){
Ext.get(html).toggleClass("cMenuParentExpanded");
});
});
Is this the best way to do it?
-
It might also be a good idea to use one click handler and use the delegate option.
Something like.
Code:
var handler = function(evnt, html){
Ext.get(html).toggleClass("cMenuParentExpanded");
};
Ext.getBody().on('click', handler, scope, {delegate: '.cMenuParentCollapsed'})
-
Thanx!
Didnt know about that!, thanx!