I’m trying to make a modification to the functionality of Eric Hynds’s jQuery IdleTimeout plugin and not having much luck. When ‘onTimeout’ is called, I’m trying to trigger the ‘onResume’ function to start the timer again and then close the dialog window. When it’s working, you should see the dialog window upon idle, and then disappear and then reappear after the same idle time – in a loop. Why a loop? I’m going to be adding more to the ‘onTimeout’ call once I get this part working.
Here’s my code, I know from firebug that my issue is with how I trigger the onResume call (line 9). The plugin binds the ‘onResume’ call to the click event via the dialog window, but obviously there won’t be a user click in this instance.
$.idleTimeout('#dialog', 'div.ui-dialog-buttonpane button:first', {
idleAfter: 5,
warningLength: 5,
pollingInterval: 2,
keepAliveURL: 'keepalive.php',
serverResponseEquals: 'OK',
onTimeout: function(){
$(this).dialog('close');
self.onResume();
},
onIdle: function(){
$(this).dialog("open");
},
onCountdown: function(counter){
$countdown.html(counter); // update the counter
}
});
Thank you for your help!
This is not quite true. The plugin binds the “Resume” link to an internal function that actually pings the server, then calls whatever onResume callback you’ve defined. You’re trying to call onResume() directly — which is OK, but it’s not going to actually resume your session.
You might be better off mimicking a click on the Resume link directly, like so: