As of right now this is the code that I using to dynamically create the <div>
inside the widgets
div. There is a list of checkboxes and upon clicking the add button , divs of ids with the values of checked boxes are created dynamically. But upon refreshing the dynamically created divs are destroyed. How can I save the dynamically created divs.
HTML
<div>
<input type="checkbox" name="basic_line" value="basic_line">Basic line<br>
<input type="checkbox" name="pie_chart" value="pie_chart">Pie Chart<br>
<input type="button" value="Add" id="btnClick">
</div>
<div id="widgets" class="span6"></div>
JS
$(function(){
$('#btnClick').click(function(){
var val = [];
$(':checkbox:checked').each(function(i){
val[i] = $(this).val();
});
for (var value in val){
$( "#widgets" ).append( "<div class = "+val[value]+
">"+'<input type="button" value = "Remove" onClick="remove_widget(\'' + val[value] + '\')" />'+
"<div id="+val[value]+" style='height: 300px'></div></div>");
create_widget();
$( "#"+val[value] ).draggable();
}
});
});