Set Dialog in tabs using JQuery

Set Dialog in tabs using JQuery


I opened some dialogs while loading the page. Then I switched to other
tab by destroying all the dialogs. Then from tab2 when I click tab1,
dialogs are not opening. Please help
<script>
$(document).ready(function(){
//$("#example").parents(".ui-dialog").is(":visible");
    $("#example").dialog_w1();
    $("#example2").dialog_w2();
    $("#example3").dialog_w3();
    $("#example4").dialog_w4();
    $("#example5").dialog_w5();
    $("#example6").dialog_w6();
    $("#example7").dialog_w7();
    $("#example8").dialog_w8();
    $("#example9").dialog_w9();
});
</script>
<script>
$(document).ready(function() {
$('#tabvanilla > ul').tabs({
select: function(e, ui) {
},
show: function(e, ui) {
var murl = ui.tab;
var nurl = murl.toString().split("#");
var ourl = nurl[1].split("-");
if(ourl == "HomePage")
{
         alert($("#example").parents(".ui-dialog").is(":visible"));
    $("#example").dialog_w1('open');
}else{
         alert($("#example").parents(".ui-dialog").is(":visible"));
    $("#example").dialog_w1("destroy").remove();
    $("#example2").dialog_w2("destroy").remove();
    $("#example3").dialog_w3("destroy").remove();
    $("#example4").dialog_w4("destroy").remove();
    $("#example5").dialog_w5("destroy").remove();
    $("#example6").dialog_w6("destroy").remove();
    $("#example7").dialog_w7("destroy").remove();
    $("#example8").dialog_w8("destroy").remove();
    $("#example9").dialog_w9("destroy").remove();
}
}
});
});
</script>