我正在实现Timeout-Dialog.js在 ASP.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'
最佳答案
请引用: documentation
问题出在插件Timeout-Dialog.js
将插件中的 $(this).dialog('close')
替换为 $('#timeout-dialog').dialog('close');
关于javascript - 超时-Dialog.js 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36773204/