I'm trying to write a custom in-window confirm dialog (based on jQuery UI) that we can use to control all aspects of the window (button text, etc). What I'd really like is for the control to behave exactly the way that the built-in confirm() function behaves (call confirm(), script execution pauses until the user clicks ok or cancel, confirm() returns true or false). I have looked around to find solutions for this, and the closes that I have come looks something like this:
//title = text to be displayed for title
//text = text to be displayed in body of dialog
//func = name of function to be called upon user selection, result will be passed as first parameter
function aw_confirm(title, text, func){
<%= ClientID %>_retVal = null;
<%= ClientID %>_func = func;
<%= ClientID %>_show(title, text);
<%= ClientID %>_waitForSelection(func);
}
function <%= ClientID %>_waitForSelection(func){
if (<%= ClientID %>_retVal != null){
var r = <%= ClientID %>_retVal;
<%= ClientID %>_retVal = null;
func(r);
}
else setTimeout("<%= ClientID %>_waitForSelection(<%= ClientID %>_func)", 10);
}
This is an aspx control, thus the <%= ClientID %>_ before everything in order to make sure that nobody overwrites the functions with code in other controls.
As you can see, this current setup requires the programmer to write a handler (here called func) to be called when the user makes a selection. What I'd really like is for aw_confirm() to just wait until the user makes a selection and then return. Is there a way to do this? Thanks in advance for any help or advice you can provide!