Hybrid View
-
10 Jul 2009 9:32 AM #1
Unanswered: Extjs Core cuestion
Unanswered: Extjs Core cuestion
Hi! I need to add the click event for each element of the CompositeElement and toggle its own class.
when i do this, i can click on any item but it will only toggle the last item :SCode:arr = Ext.select('.cMenuParentCollapsed'); arr.each(function(){ this.on("click",function(e,t){ this.toggleClass("cMenuParentExpanded"); }); });
What i'm i doing wrong?
Thanx!
-
10 Jul 2009 9:41 AM #2
FIXED
FIXED
Got it working :S
Is this the best way to do it?Code:arr = Ext.select('.cMenuParentCollapsed'); arr.each(function(){ this.on("click",function(evnt,html){ Ext.get(html).toggleClass("cMenuParentExpanded"); }); });
-
11 Jul 2009 7:39 AM #3
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'})James Demspter
the one constant in life, is change.
-
11 Jul 2009 10:54 AM #4


Reply With Quote