Update after adding div dynamically using jQuery Mobile

I am trying to add dynamic div syntax using jQuery mobile, but after adding it CSS is not applied even when updating .

This is an example .

Code:

$(function() { $("#data").append('<div data-role="collapsible"><h3>Div2</h3><p>Content Div2...</p></div>'); $("#data").listview("refresh"); }); 
+4
source share
2 answers

Use collapsibleset() instead of listview("refresh") :

 $("#data").collapsibleset(); 

See DEMO .

+4
source

I use this method

 try{ $("#data").listview("refresh"); }catch{ $("#data").listview(); }finally{ $('[data-role=collapsible]').collapsible(); } 

This issue occurs when an item is added to a dynamic

0
source

Source: https://habr.com/ru/post/1469361/


All Articles