I'm thinking that you need to move this
$("#mydialog").dialog({modal:true, autoOpen:false, title:Title,
width:800, height:380});
out of the open OpenDialog function and have that in your document
ready function
see whats happening is that it creating a new instance of .dialog
every timeyou call OpenDialog()
I'm not sure if used the right terms there but that's essentially
whats happening
Mean Mike
On Oct 30, 9:54 pm, Rushi <[email protected]> wrote:
> Hi,
>
> I have a strange problem with JQuery modal dialog. I am using the
> following code to open my dialog.
>
> function OpenDialog()
> {
> UpdateDIVForThisDialog();
> $("#mydialog").dialog({modal:true, autoOpen:false, title:Title,
> width:800, height:380});
> $("#mydialog").dialog("open");
>
> }
>
> function UpdateDIVForThisDialog()
> {
> var URL = "MyURL";
> var Parameters = "MyParameters";
>
> $.ajax({
> url: URL,
> async: false,
> data: Parameters,
> cache:false,
> type: "GET",
> dataType: "html",
> success: function(UserData)
> {
> document.getElementById("mydialog").innerHTML = UserData;
> }
> });
>
> }
>
> It's a straightforward piece of code that gets some data via an AJAX
> call and updates the innerHTML of the div tag that is then used by the
> OpenDialog function. The strange thing happening is that the div's
> innerHTML seems to be cached when the dialog is opened. This leads to
> the dialog showing the HTML of the earlier AJAX call. Please note that
> the AJAX call does return me the new HTML because I displayed it using
> an alert and I did see the new HTML. I also did an alert on
> document.getElementById("mydialog").innerHTML and I see that the "new"
> HTML content is set to the div tag. But, somehow, when the dialog is
> opened, it shows me the old HTML. If it helps, the HTML is retrieved
> from a MVC View and I tried setting the cache-control and all such
> properties so there is no caching. But, I don't think thats the
> problem because I do get the new HTML back from the server. It's the
> dialog that somehow remembers the old div tag contents. If I refresh
> the browser, I do see the correct contents in the dialog. The issue
> happens in IE, Firefor and Chrome. So, I don't think it's browser
> specific. I tried destroying the dialog before opening but it doesn't
> work either. I am unable to find out the reason for this strange
> behavior. Any help would be greatly appreciated.
--
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en.