事件发生时打开对话框
通常我们希望将对话框的创建与其外观分开。然后需要三个步骤。
- 创建基本元素
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
- 将其设为对话框,注意
autoOpen: false
选项,确保首先关闭它
$( "#dialog" ).dialog({
autoOpen: false
});
- 在需要时打开它,就像点击按钮一样
$( "#dialog" ).dialog( "open" );