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
精彩评论