I have placed my jquery dialog content in a div. But whenever I'm initializing the dialog in this way:
$(".uof_add_form").dialog({
autoOpen : false,
height : 500,
width : 600,
modal : true,
buttons : {
"Done" : function() {
$(this).close();
}
}
});
The content gets removed from my div. And for this reason I can not use
$("#new_form").on("click",".add_level", function(){
var wrapper_data = $(this).parent().parent().parent().parent();
wrapper_data.find(".uof_add_form").dialog("open");
});
to open my dialog.
As my contents are generated dynamically I need to use $(this).
Is there any way with which my content will stay inside of my div?
I changed my code to initialize on the click itself doing display:none on my div in this way:-
$("#new_form").on("click",".add_level", function(){
var wrapper_data = $(this).parent().parent().parent().parent();
wrapper_data.find(".add_level_pop").dialog({autoOpen : true, height : 500,width : 600,modal : true, buttons : { "Done" : function() { $(this).dialog('close'); } } });
});
The dialog opens on first click but on second click the dialog doesn't gets fired because the content has been transferred to a different place on initialization of the dialog.
I have also added a sample on jsfiddle please check here