开发者

How to prevent disposing a jQuery modal dialog

i have such a function wh开发者_运维知识库en it is invoked a dialog is created, after the dialog is closed and the button is clicked again, the dialog doesn't showup

$("#Button").click(function() {
                $.ui.dialog.defaults.bgiframe = true;
                                $("#box").dialog({
                                    modal: true,
                                    draggable: true,
                                    width: 600  
                                });
                               });

whats wrong here?


Use something like this:

$( document ).ready ( function () {
    $.ui.dialog.defaults.bgiframe = true;
    $( "#box" ).dialog ( {
        modal: true,
        autoOpen: false,
        draggable: true,
        width: 600  
    } );

    $( '#Button' ).click ( function () {
        $( '#box' ).dialog ( 'open' );
    } );
} );

The catch is that you only init the dialog once, and then call .dialog ( 'open' ), when you actually want to open the dialog

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜