lachezar Posted September 1, 2012 Posted September 1, 2012 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 secondsvar 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); });
Shinryuu Posted September 1, 2012 Posted September 1, 2012 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.
lachezar Posted September 1, 2012 Author Posted September 1, 2012 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.
Shinryuu Posted September 1, 2012 Posted September 1, 2012 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now