0
votes

I get the following error: Uncaught Error: cannot call methods on dialog prior to initialization; attempted to call method 'close'

When using the following jquery script:

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

The specific errors in dev tools are here

and I invoke the function 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});
     });
    }); 

Simply can't get it to be functional

1

1 Answers

1
votes

timeout-dialog.js plugin doesn't work probably from jQuery 1.7. In the official repository of this plugin there is a pending Pull Request for merge and there is a fix for your bug.

You should download timeout-dialog.js file to your local resources and then modify the function destroyDialog in timeout-dialog.js file like below:

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