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

Posted

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);

 

});

Posted

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.

Posted

Loop definitely makes sense.I have to look into that.

I thought it might be as easy as just move the function around but unfortunately i do not have much experience with javascript either.

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...