Jump to content

How To Recall A Function And Have The Dialog Box Keep Coming Back When Click 'cancel' Button With Jquery In This Example? I Am Sure It Is Easy But Sti


Recommended Posts

How to recall a function and have the dialog box keep coming back when click 'cancel' button with Jquery in this example? I am sure it is easy but still learning some of the basics here. Thanks

 

 

 

var autoCloseTimer;

var timePeriod = 5000; // 10 seconds

var warnPeriod = 15000; // 15 seconds

 

function definitelyClose() {

alert('Hello');

//window.location = 'http://www.advantagene.com'

};

 

 

$(document).ready(function() {

$('#proba').dialog({ autoOpen: false });

 

setTimeout(function (){

autoCloseTimer = setTimeout('definitelyClose()',warnPeriod);

$('#proba').attr('title', 'Warning').text('Sesion will expire').dialog('open');

 

$('#proba').dialog({buttons:{'Cancel':

 

function() {

$(this).dialog('close');

clearTimeout(autoCloseTimer);

 

 

}

 

 

} });

 

 

 

 

}, timePeriod);

 

});

Link to comment
Share on other sites

I think maybe this will help: http://stackoverflow.com/questions/5112405/how-do-i-get-a-jquery-statement-to-wait-until-its-completed-before-continuing

 

The difference in implementation is you need a variable to use in a while loop or some such thing, or create a label and goto that label when cancel is hit, I'm not sure if the label & goto is possible in js though because I'm not a JavaScript programmer.

Link to comment
Share on other sites

Might be possible to make the function call itself in the Cancel button's function declaration to cause an infinite loop, but I'm thinking this might stack a dialog on top of the current one when a user clicks cancel. Worth a try though I'd think.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...