timeout-dialog.js
timeout-dialog.js copied to clipboard
Incompatible with newer jQuery Versions
Error message
With newer versions of jQuery and jQuery UI the following error occurs whenever destroyDialog()
is triggered:
Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'
Test code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Timeout Dialog</title>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/timeout-dialog.js"></script>
<link rel="stylesheet" href="css/index.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="css/timeout-dialog.css" type="text/css" media="screen, projection" />
</head>
<body>
<div>
<a href="#" id="timeout-example">Click Here to See Demo</a>
</div>
<script type="text/javascript">
/*<![CDATA[*/
$(function () {
$("#timeout-example").click(function(e) {
e.preventDefault();
$.timeoutDialog({timeout: 1, countdown: 60, logout_redirect_url: 'https://github.com/rigoneri/timeout-dialog.js', restart_on_yes: false});
});
});
/*]]>*/
</script>
</body>
</html>
This was the highest combination of jQuery and jQuery UI I could get this to function properly.
https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js
This appears to be fixed by pull request 8 though it hasn't been accepted yet: https://github.com/rigoneri/timeout-dialog.js/pull/8 Basically you need to change the line in the destroyDialog function from $(this).dialog("close"); to $("#timeout-dialog").dialog("close");
Works for me in 1.11.0