I have 2 functions. First contains Jquery-UI dialog and called from the Second function. Something like :
function First() {
$('div').dialog({
buttons: {
"Ok": function () { /* code */
}
}
});
}
function Second() {
First();
/* rest of this function code is depend upon the "Ok button"
function code */
}
Now my problem is that after calling function First the execution of script doesn’t wait for dialog's Ok button press. Whats should i do, so that only after pressing the Ok button, the control return from the function First?
Move from the function
Secondthe part after callingFirstinto a 2nd function (here calledSecondOkHandler). CallFirstwith a new parameter (this callback function) and in the functionFirston ‘ok’ call this:Also see this example.
=== UPDATE ===
To make it more complex, here a link to an example with more callbacks.