javascript - 超时-Dialog.js 问题

标签 javascript jquery jquery-ui asp.net-mvc-5 timeout-dialog.js

我正在实现Timeout-Dialog.jsASP.NET MVC 5 项目中。

所以在我的布局页面上我有

 <script type="text/javascript" language="javascript">

        $(function () {
            Timer();
        });

        function Timer() {
            console.log("Set Timeout");
            setTimeout(TimeOut, 10000);
        }

        function TimeOut() {
            $.timeoutDialog({
                timeout: 1,
                countdown: 60,
                keep_alive_url: '@Url.Action("KeepAliveSession", "Account")',
                logout_redirect_url: '@Url.Action("Login", "Account")',
                logout_url: '@Url.Action("LogOff", "Account")',
                restart_on_yes: true
            });
        }
    </script>

我将所有文件包含到 BundleConfig 中。

   public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                      "~/Scripts/jquery-{version}.js",
                       "~/Scripts/jquery-ui.min.js",                       
                       "~/Scripts/jquery.dataTables.min.js",
                      "~/Scripts/dataTables.jqueryui.min.js ",        
                      "~/Scripts/timeout-dialog/js/timeout-dialog.js"
                      ));

    bundles.Add(new StyleBundle("~/Content/css").Include(
                   "~/Content/bootstrap.css",
                   "~/Content/site.css",
                   "~/Content/main.css",
                   "~/Content/jquery.dataTables.min.css",                
                   "~/Content/jquery-ui.css",
                   "~/Content/dataTables.jqueryui.min.css",
                   "~/Scripts/timeout-dialog/css/timeout-dialog.css"

               ));

该对话框及时出现,但是当我按任何按钮时,我都会遇到此错误。

Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

enter image description here 知道如何修复它吗?

最佳答案

请引用: documentation

问题出在插件Timeout-Dialog.js

将插件中的 $(this).dialog('close') 替换为 $('#timeout-dialog').dialog('close');

关于javascript - 超时-Dialog.js 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36773204/

相关文章:

javascript - 多张图片叠加效果

jquery - 正则表达式:在单词后的下一个换行处拆分

jquery - 无法获得 jquery 自动完成样式

php - 如何使用 javascript 序列化关联数组并将其保存在 cookie 中,然后使用 php 读取它?

JavaScript 无法显示数组中的图像

javascript - 如何使用 JavaScript 将 JSON 字符串中的值提取到列表项中

jquery - 如何限制使用 jquery 的 LI 数量

java - 定位装置(相交圆)

jquery - 在 jQuery 中增加 PHP 值+1(如按钮)

c# - 如何使用 c#/jquery/javascript/silverlight 生成两个或多个不同设计图 block 的可能排列?