jQuery Dialog Won't Open Twice

Hi,

I'm loading a jQuery dialog with content AJAX style, and my dialog opens fine the first time, but not the second time.  I can get it to open as many times as I want ONLY if I have my dialog div on the same page, but int this case, I have my one page with the dialog, but the content is pulled in via the "success" call from the ajax.

I have a tabular grid with rows of data.  In one of the columns there is a button, the user clicks this button and it calls the below function "showMyWindow()".

I'm calling dialog('open') as you can see on line 29, but it won't open the second time. Here is my code:

function showMyWindow(someValue) {
	
		var url = "view/ajaxcontent.php";
		var tag = $("<div></div>");

		
			$.ajax({
				url: url,
				cache: false,
				type: "POST",
				data: { customerId: someValue },
				success: function(data) {
										
					tag.html(data).dialog({
						modal:true,
						cache: false,
						title: 'Customer Information',
						autoOpen: false,
						closeOnEscape: true,
						width: 350,
						height: 250,
						zIndex: 5000,
						buttons: false,
						position: "center",
						close: function(event, ui) {
							$(this).dialog("close");
					
						}
					}).dialog('open');
					
					
				} // close success
				
			}); // close ajax
		
		return false;
}

Open in new window

LVL 1
Westside2004Asked:
Who is Participating?
 
Luis PérezSoftware Architect in .NetCommented:
You must destroy it before showing again. Replace your

close: function(event, ui) {
    $(this).dialog("close");
}

with

close: function(event, ui) {
    $(this).dialog("destroy");
}

Hope that helps.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.