简体   繁体   English

无序关闭模式jQuery对话框会导致IE错误

[英]Closing modal jQuery dialogs out of order causes error in IE

As part of dropping support for older browsers, I recently updated an ASP.NET app to jQuery 3.1.1 and jQuery UI 1.12.1. 作为不再支持较旧浏览器的一部分,我最近将ASP.NET应用程序更新为jQuery 3.1.1和jQuery UI 1.12.1。 After this, I noticed that I was getting errors logged to the console in IE 11. 此后,我注意到我在IE 11中将错误记录到控制台。

The error is as follows: 错误如下:

 SCRIPT5007: Unable to get property '_focusTabbable' of undefined or null reference jquery-ui.js, line 12794 character 7 

I was able to track the problem to the fact that long-running calls (eg database query that may take 2-3 seconds) open a 'Please Wait' modal dialog. 我能够将问题跟踪到以下事实:长时间运行的呼叫(例如,可能需要2-3秒的数据库查询)会打开“请稍候”模式对话框。 This dialog is closed after a content dialog is opened and populated. 打开并填充内容对话框后,将关闭此对话框。 When the content dialog is closed, the above error occurs. 当内容对话框关闭时,会发生上述错误。

I was able to condense the issue into the following JSFiddle: https://jsfiddle.net/qaf1ut4b/8/ 我能够将问题压缩到以下JSFiddle中: https ://jsfiddle.net/qaf1ut4b/8/

What do I need to do to be able to have a wait dialog open until after the content dialog is opened and populated? 要打开一个等待对话框,直到打开并填充内容对话框后,我需要做什么? Closing the wait dialog first solves the problem, but isn't sufficient as the content dialog can take a long time to populate, due to large numbers of <option> elements being loaded into the DOM after the database query completes. 关闭等待对话框首先可以解决问题,但是这并不足够,因为在数据库查询完成后,大量的<option>元素已加载到DOM中,因此内容对话框可能需要很长时间才能填充。

If you are OK with destroying the modals when you close them you can use this: 如果您可以在关闭模态时销毁它们,可以使用以下方法:

$('#wait-dialog').dialog({
        autoOpen: false,
        height: 88,
        width: 250,
        modal: true,
        title: 'Please Wait',
        close: function (event, ui) {
            $(this).dialog('destroy');
        },
        open: function () { }
    });

$('#content-dialog').dialog({
        autoOpen: false,
        height: 188,
        width: 350,
        modal: true,
        title: 'I Am Some Content',
        close: function (event, ui) {
            $(this).dialog('destroy');
        },
        open: function () { }
    });

Here is the fix to your jsfiddle: 这是您的jsfiddle的修复程序:
https://jsfiddle.net/qaf1ut4b/9/ https://jsfiddle.net/qaf1ut4b/9/

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

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