I have implemented a JQuery Dialog to replace all standard alert() and co开发者_如何学JAVAnfirm() to give a better look and feel.
The problems is these are async call and in most places I can use the callback method to fire the action after user response.
But in another plugin I can utilise the callback so need this to be syncronous.
Example:
- some js code
- dialog
- more js code
Line 1,2 & 3 are fired before line 2 dialog has been completed by the user. I dont need the response from the dialog just for it to stop the execution of line 3.
here is an example of what i think u want to do:
fiddle: http://jsfiddle.net/maniator/32BWw/
js:
function step_one(){
$('body').append('hello');
step_two();
}
function step_two(){
$('<div>').dialog({
modal: true,
buttons: {
ok: function(){
$(this).dialog('close');
}
},
beforeClose: function(){
step_three();
}
}).html('you sure?')
}
function step_three(){
$('body').append(' there');
}
step_one();
you need callbacks for the closing dialog step
精彩评论