Since the required classes were not being applied to the child nodes dynamically, I have come up something that's definitely not the best solution but gives me an effective workaround for now: I pre-create collapsible nodes - these will automatically have all required styling applied to their children. At run-time, when I need to create the nodes dynamically, I make copies of the 'template' node (using clone) and append them to the root nodes with with appropriate modifications.
In one instance (dynamically adding a list to a div) the solution was to not have any IDs in my HTML and I had to replace all IDs with classes. Its ugly, slower, and wreaks of voodoo coding. I really hope this gets solved in a3.
Not sure if this well help anyone as this post is very old but I was recently trying to use templates and mobile framework to create collapsible sets. Nothing seemed to work until i placed the code for getting the data and setting the template before the definition of the mobile js files.
Works like a charm now with no special work arounds. Hope this helps someone.
I think I see what you are doing, but this may not be the best way to do it. The reason is you get the data before JQM enhances the data. While this is fine, it won't help for every case. What you really need to do is find the correct 'create' or 'refresh' method to apply to the dynamic content. There are plenty of threads about this.
... This thread is 1 year old. Who didn't make good use of it? The only person not making good use of it is you! All the answers above WERE correct, they are just out dated...
As I stated to the other late response, you need to find the correct 'refresh' or 'create' method which is found in the official jquery mobile documentation FOR the version you are using. There are many threads about adding dynamic content.
To my point above:
The first tutorial you gave is extremely out dated. There is some incorrect information there. While it does look like a useful site, I would proceed with caution.
You linked to the test version of documentation. What you really should do is link to the documentation version the OP is using, not link test documentation.