简体   繁体   English

IE8无法使用jQuery对话框

[英]IE8 not working with jQuery Dialog

I have an HTML form: 我有一个HTML表单:

<div id="dialog" class="event-dialog" title="Create Event">
    <div id="dialog-inner">
    <table>
        <tr><td align="left">Event Name:</td><td align="left"><input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all title"></td></tr>
        <tr><td align="left" valign="top">Event Description:</td><td><textarea name="description" id="description" class="text ui-widget-content ui-corner-all" rows="3" cols="40"></textarea></td></tr>
        <tr><td align="left">All Day Event:</td><td align="left"><input id="all-day" type="checkbox" value="false"></td></tr>
     </table>
     </div>
</div>

I also have the following jQuery code: 我也有以下jQuery代码:

jQuery("#dialog").dialog({
    autoOpen: false,
    height: 600,
    width: 700,
    modal: true,
    buttons: {
        'Create event': function () {
            name = jQuery("#name").val();
            jQuery(this).dialog('close');
        },
        Cancel: function () {
            jQuery(this).dialog('close');
        }
    },
    close: function () {
    }
});

I removed some stuff in my jQuery code just to shorten it up for StackOverflow. 我删除了我的jQuery代码中的一些内容,只是为了将其缩短为StackOverflow。 The code works in Chrome, Firefox, Safari, etc., but, for some reason, it just displays the dialog form in IE8. 该代码可在Chrome,Firefox,Safari等环境中运行,但是由于某些原因,它仅在IE8中显示对话框形式。 Any idea why it wouldn't hide the form in IE8? 知道为什么它不会在IE8中隐藏表单吗?

I had a similar problem, but my solution was another: On my website there are some flash objects. 我遇到了类似的问题,但我的解决方案是另一个问题:我的网站上有一些Flash对象。 These objects are rendered by IE permanently in foreground. 这些对象由IE永久呈现在前景中。 The result is, the dialog appears behind the flash objects, and I see only the lockscreen without a dialog. 结果是,对话框出现在Flash对象的后面,而我只能看到锁屏而不显示对话框。

My ugly solution: I hide the flash objects before the dialog is shown. 我的丑陋解决方案:在显示对话框之前,我隐藏了Flash对象。 When the dialog is closed, I show the objects again. 关闭对话框后,我再次显示对象。 That works. 这样可行。

I had the same thing happen to me a while ago. 不久前,我也发生了同样的事情。 Is this your exact HTML code? 这是您的确切HTML代码吗? If not, make sure you don't use self-closing tags within the dialog div. 如果不是,请确保在对话框div中不使用自动关闭标签。

 <div id="dialog-save">
    <div id="content" /> //this one didn't work.
    <div id="content"></div> //this one worked.
 </div>

For some reason, IE doesn't like self-closing tags for jquery-ui. 由于某些原因,IE不喜欢jquery-ui的自关闭标签。

In my case an extra closing div is creating problem. 就我而言,一个额外的关闭div会造成问题。

<div class="comment_video"  >
 // content
</div>
</div>  // this closing div is creating problem.

I have removed the last extra closing div and it's working fine. 我删除了最后一个关闭的div,它工作正常。 It look like IE 8 very strict with HTML standards 看起来IE 8对HTML标准非常严格

I hope it helps. 希望对您有所帮助。

I found the same bug by adding CSS class with jQuery like : 我通过使用jQuery添加CSS类发现了相同的错误:

jQuery( "#dialog-noresult" ).dialog({
    modal: true,
    autoOpen: false,
    width: 500,
    height: 630,
    buttons: {
        "Cancel": {
             text: 'Cancel',
             class: 'dialog_Cancel',
             click: function() {
                 jQuery( this ).dialog( "close" );
             }
    }, ...
});

And I solved it by adding quote to the class option. 我通过在类选项中添加引号来解决它。

"class":'dialog_Cancel',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM