0

Is there a way to add a listview to a collapsible which is in a collapsible-set node.

I am doing this completely from javascript/jquery.

I only have 1 base node in the html

    <div data-role="collapsibleset" data-inset="false" data-collapsed="false" id="coll" data-content-theme="a" data-iconpos="right">

    </div>

I make an ajax call to a nested json call, with children of children and need to add collapsibles and listviews to this node. usually the listviews are children of collapsibles but sometimes there is a collapsible with a collapsible and a listview.

I am doing this all in script. I don't know why it came to this, I was using a tree, but the jquery mobile buttons seemed more phone app like. I can add the collapsible with a

var final = "<div data-role='collapsible' id='" + title + "'><h3>" + title + "</h3></ul>"
$('#coll').append(final).collapsibleset('refresh');

but then I got my listview....

var items = "<ul data-role='listview' data-inset='false' id='lv" + title + "'>"<li>test</li>"</ul>";

I think there is a .listview("refresh") but I don't know if I have to refresh my collapsible first and then my listview.

thanks for any advice or help.

matthewbaskey
  • 1,027
  • 2
  • 17
  • 40

1 Answers1

0

Depending on the Version of jQM you can (on 1.4) simply call

$('#coll').trigger("create");

which should create all subsequent jQM code - you could even do this on the whole page once finished - on cost of performance. For the listview only you would (once you removed a few " ):

$('#lv').listview().trigger("refresh");
Chris
  • 580
  • 5
  • 17