我正在學習如何使用jQuery對話框。我發現一個有用的鏈接是http://imperavi.com/redactor/examples/uidialog/。代碼列在下面,但我不知道爲什麼它不起作用。jQuery對話框:如何使用?
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Dialog</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<p><a href="javascript:void(null);" onclick="showDialog();">Open</a></p>
<div id="dialog-modal" title="Basic modal dialog" style="display: none;"></div>
<script type="text/javascript">
function showDialog()
{
$("#dialog-modal").dialog(
{
width: 600,
height: 400,
open: function(event, ui)
{
var textarea = $('<textarea style="height: 276px;">');
$(textarea).redactor({
focus: true,
autoresize: false,
initCallback: function()
{
this.set('<p>Lorem...</p>');
}
});
}
});
}
</script>
</body>
</html>
謝謝你的幫助!
添加jquery-ui和css後出現對話框,但「
Lorem ...
」未顯示。再次感謝。
還有一件事...是否可以傳遞一個字符串到「showDialog」,以便它可以顯示基於不同鏈接的不同內容?例如,添加「打開1」和「打開2」以顯示不同的字符串?
再次感謝您。
對話框不是標準庫,但JQuery的一部分UI! http://jqueryui.com/ 你也必須包括這一點。不要忘記獲取主題,否則會變得非常難看。 http://jqueryui.com/themeroller/ – androidavid
...這意味着你需要單獨加載它。 –