AccordionItem open/close state

AccordionItem open/close state

I have an Accordion with several AccordionItems in it - AND - I need to be able to test to see if a given AccordionItem is open or closed.

I could do this in a screen action or in some custom JS code - either way.
BUT, I know that I can call the "click()" method - but - how can I tell of the accordion item is already open ?


Hi Bruce.

You can validate that using a jQuery selector to check if it's open or not.

Meaning, if for instance the only think that changes is the css attribute display, you can get the display value and if is display:none if should be closed. 

Here's an example:

if ( $('<your element or css class>').css('display') == 'none' )  ---> The element is closed, else is open.

If you're using the Accordion given ny the SilkUI, the only difference is that a class called expanded is added to the element. So for this scenario you can use a selector like:

if ( $('<your element or css class>' ).hasClass( 'expanded' ) )  ---> The element is open, else is closed.

According to the value, you can do what you need/want.

Hope it helps.

Thanks for the info - I will try that next time. As it turns out, I already changed the Accordion widget to instead use the SectionExpandable and then updated the CSS to move the carrot to the let so it looks like an Accordion.

So, next time I have an Accordion I will give this a try thanks!