views:

2475

answers:

4

Hi, I'm having some trouble with IE6 and jQuery UI. I have a popup dialog (modal, if it matters), that displays a "yes/no" dialog to the user with some information. In order to facilitate this, I build the dialog with autoOpen = false, and then I call $('#popup').show() later on as needed, in response to various different events. Now, in IE6 (and only IE6, as far as I can tell), the .dialog method will occasionally fail but STILL return the jQuery object. So, rather than show a popup, the .show() method just display a div container in the html page.

What could be causing this, and how I can fix this behavior?

Thanks.

$('#myDialog').dialog({
            autoOpen: false,
            buttons: {
                "No": function()
                {
                    $(this).dialog('close');
                    //do stuff
                },
                "Yes": function()
                {
                    $(this).dialog('close');
                    //do stuff
                }
            },
            draggable: false,
            modal: true,
            resizable: false,
            title: "Confirmation",
            width: "500px",
            zIndex: 2000
        });

and later

$('#myDialog').dialog('open').show();

Pretty standard.

New information

I'm loading the page that makes the dialog with ajax inside of another dialog, which can be repeatedly created and destroyed. Now, each time my page gets loaded with ajax, .dialog(opts) should re-instantiate the dialog div, correct? I've found that this is the scenario.

1.) An outer dialog uses ajax to replace its content with my content.

2.) My content launches a dialog that was previously created and set to not autoopen.

3.) The outer dialog is destroyed as the inner dialog is closed.

4.) The outer dialog is reopened. The inner dialog no longer is able to appear as a dialog in ie6. This ONLY happens in ie6.

+6  A: 

You should open your dialog using

$('#myDialog').dialog('open');

instead of

$('#myDialog').show();

The first method displays actual dialog box, while the one you are using just causes the #myDialog item to be displayed (with no UI Dialog magic). show() method is the part of the core jQuery library and shoudn't be used to invoke a dialog.

RaYell
My fault. I erred.I'm using $('#blah').dialog( 'open' ).show();The content is hidden until the dialog is created.
Stefan Kendall
You don't need to run show() method after dialog('open'), UI Dialog will automatically make the content of $('#blah') visible
RaYell
No, it won't. At least not in any IE variant. I've thoroughly tested this scenario.
Stefan Kendall
I'm sorry, but you are wrong. I've prepared a little demo proving that you don't need to use show() method. Have a look at http://stuff.rajchel.pl/js/modal.html
RaYell
Load dialog 1. Load data via ajax for dialog 2. Open dialog2 as a modal dialog. Doesn't work. You have to show it, and I still have the problem REGARDLESS of the text just pushing to the bottom of the document, rather than showing in an actual popup. You've done nothing to address my initial problem aside from spouting what you believe to be correct semantics and ignoring to address the core problem.
Stefan Kendall
+1  A: 

I had a similar situation and was never able to reuse the dialog. I had to destroy and recreate both dialogs each time.

Geoff
Destroying and recreating seems to mess with the behavior of the "modal" dialogs. As in, the grey dimming bit isn't removed. Perhaps closing AND destroying? I think I'm going to go try that.
Stefan Kendall
I just retried this, as it seemed the only possible solution, and I got it working the second 'round through. I thought crazy crashing had to be incorrect behavior :P.Thanks so much!
Stefan Kendall
+1  A: 

Hi,

I use the bgiframe: true and I never got any problem with them with I6, FFox, etc.

More info: http://docs.jquery.com/UI/Dialog#option-bgiframe

Regards.

ATorras
I've had bgiframe since the start of development. No dice.
Stefan Kendall
Anyone reading this: bgiframe is essential for ie6 and jquery-ui. This was unrelated to my problem, but you'll get headaches without bgiframe.
Stefan Kendall
A: 

By the way, when you are hiding your modal before you open it, are you using style="display:none" as your hiding attribute, or a CSS class, or jquery?

The reason I ask, is that if you use simply style="display:none" I never have problems with the modal showing the modal perfectly all the time using dialog("open") but if I use either css or jquery, I always have problems.

You may want to test it.

Marcus

Marcus Eby