开发者

JQuery Dialog syncronous call

开发者 https://www.devze.com 2023-02-22 18:47 出处:网络
I have implemented a JQuery Dialog to replace all standard alert() and co开发者_如何学JAVAnfirm() to give a better look and feel.

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:

  1. some js code
  2. dialog
  3. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消