這是我正在嘗試做的一個示例。如何確定一個元素是否配置了對話框?
<html>
<head>
<script type="text/javascript" language="javascript">
function doOpen() {
if ($('#dialog-modal').dialog('widget') == '')
document.getElementById('#dialog-modal').style.display = 'block';
else
$('#dialog-modal').dialog('open');
}
function doClose() {
if ($('#dialog-modal').dialog('widget') == '')
document.getElementById('#dialog-modal').style.display = 'none';
else
$('#dialog-modal').dialog('close');
}
function doAttach() {
$('#dialog-modal').dialog({
width: 'auto',
height: 'auto',
title: 'Popup Dialog',
autoOpen: false,
resizable: false,
modal: true
});
document.getElementById('dialog-modal').style.display = 'block';
}
</script>
</head>
<body>
<input type="button" id="Show" value="Open" onclick="doOpen();" />
<input type="button" id="Attach" value="Attach" onclick="doAttach();" />
<div id="dialog-modal" style="display:none">
Show this in a model dialog window<br />
<input type="button" id="Close" value="Close" onclick="doClose()" />
</div>
</body>
</html>
如果我在做任何事情之前點擊「附加」,對話框就會顯示出來。但是,如果我先點擊「打開」,那麼我得到錯誤。我需要知道這條線應該是什麼樣,看看是否對話框的模式已經被連接到一個對話框
if ($('#dialog-modal').dialog('widget') == '')