0

Ich implementiere Timeout-Dialog.js in ASP.NET MVC 5 Projekt.Timeout-Dialog.js Problem

So in meinem Layout-Seite Ich habe

bekam
<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> 

Und ich alle Dateien in 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" 

       )); 

Der Dialog erscheint in der Zeit, aber wenn ich jede Taste drücke ich diesen Fehler bin vor.

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

enter image description here Jede Ahnung, wie man es beheben?

Antwort

1

Bitte beachten: documentation

Das Problem mit dem Plugin ist Timeout-Dialog.js

ersetzen $(this).dialog('close') mit $('#timeout-dialog').dialog('close'); im Plugin