views:

119

answers:

2

Hi there,

I tried to use "dijit.layout.AccordionPane.selected" to determine if any given AccordionPane is in focus (selected). However, AccordionPane.selected property will be set to "True" once the AccordionPane is selected, and AccordionPane.selected stays as "True" even other dijit.layout.AccordionPane is selected. So in other words, if I have 3 AccordionPanes, after I clicked on all 3 of them, AccordionPane.selected property for all 3 of them are "True" now. Is this a bug, or there is other ways to determine which AccordionPane is currently being selected (in focus)? Thanks in advance!

David

+2  A: 

You should use the dijit.layout.AccordionContainer that contains all these three dijit.layout.AccordionPane to determine which one is currently selected.

You can use dijit.layout.AccordionContainer's property selectedChildWidget to get current selected dijit.layout.AccordionPane.

Alex Cheng
Thanks a lot, I was using AccordionContainer, but didn't know to use selectedChildWidget property to check.
David Zhao
+1  A: 

AccordionPanes are wrapped within an AccordionContainer. The AccordionContainer extends StackContainer which uses Dojo's pub-sub communication channel to advertise when a pane was selected. Subscribe to topic [widgetId]-selectChild to get notified every time when a new pane is selected. [widgetId] is the widget ID of the container element.

dojo.subscribe("[widgetId]-selectChild", function(pane){
    console.log("A new pane was selected:", pane);
});
Török Gábor
Thanks for your answer too! While your suggestion is to get notified when it's selected, I was trying to find out which one is currently being selected, and I think I could do this by using onFocus().cheers!
David Zhao