Question

If I have a collapsible list in JQM, how to I get the item that is expanded?

I've tried; $("#addressMDUList").find(":selected").text() but that doesn't work.

So I have;

<div id="addressMDUList" data-role="collapsible-set" data-theme="d" data-content-theme="d">

and the sets are added programmatically. Now, just before I rebuild the list, I want to get the set the user last had open, rebuild the list, and then open that set again.

Was it helpful?

Solution

Collapsed collapsible has class ui-collapsible-collapsed, this class is removed once a collapsible is expanded. Inside a collapsible-set there should be only one expanded collapsible or none.

All you need to filter the expanded one using .not(".ui-collapsible-collapsed").

var expanded = $("col-set-id").find(".ui-collapsible").not(".ui-collapsible-collapsed");

Demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top