Dynamically Add Collapsible Elements in Jquery Mobile

I spent a long time trying to get this to work and finally success.
This code produces a div with content and then reminds the JQuery Mobile framework to actually wire it up with classes, functionality, etc.

$('<div data-role="collapsible"><h3>Title</h3><p>Content</p></div>').appendTo('[data-role="content"]');
$('div[data-role=collapsible]').collapsible({theme:'c',refresh:true});

3 comments

  1. VERY NICE! THANK YOU VERY MUCH!

    Do you know how can I append elements into the content area?

    Greetz Osman

Leave a Reply

Your email address will not be published. Required fields are marked *