Jquery Dialog error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

Jquery Dialog error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

我收到以下错误: 未捕获的错误:无法在初始化之前调用对话框上的方法;试图调用方法 'close'

使用以下 jquery 脚本时:

http://rigoneri.github.io/timeout-dialog.js/js/timeout-dialog.js

The specific errors in dev tools are here

我在这里调用函数:

    $(function () {
     $("#timeout-example").click(function(e) {
       e.preventDefault();
       $.timeoutDialog({timeout: 1, countdown: 60, logout_redirect_url: 'https://google.com', position: 'absolute', restart_on_yes: false});
     });
    }); 

根本无法正常运行

timeout-dialog.js 插件可能无法从 jQuery 1.7 开始工作。在这个插件的官方存储库中,有一个等待合并的 Pull Request,并且有一个针对你的错误的修复程序。

您应该下载 timeout-dialog.js 文件到您的本地资源,然后在超时-dialog.js 文件中修改函数 destroyDialog 如下:

    destroyDialog: function() {
      if ($("#timeout-dialog").length) {
       //$(this).dialog("close");
         $("#timeout-dialog").dialog("close");
        $('#timeout-dialog').remove();
      }
    },