[英]Why isn't my jQuery Dialog opening?
I was given some code to add to an email application I'm building so that when someone clicks the 'preview' button, a dialog will pop up and display the text as it would appear in the email. 我得到了一些要添加到正在构建的电子邮件应用程序中的代码,以便当有人单击“预览”按钮时,将弹出一个对话框,并显示与电子邮件中显示的文本相同的文本。 I've only been programming with JavaScript for about a week now and I've done my best to research how the jQuery Dialog box works, but for the life of me I just cannot get it to open when the button is clicked.
我仅用JavaScript编程大约一个星期,我已经尽力研究jQuery对话框的工作原理,但是对于我来说,单击按钮时我无法打开它。
These are the two functions I was given: 这是我获得的两个功能:
<script>
$("#loadPreviewDiv").dialog({
autoOpen : false,
resizable : true,
height : 600, //adjust accordingly
width : 600, //adjust accordingly
modal : true,
buttons : {
close : function() {
$(this).dialog("close");
}
},
});
function loadPreviewView() {
document.getElementById('loadPreviewDiv').innerHTML = 'htmlBody.innerHTML';
$("#loadPreviewDiv").dialog("open");
} </script>
And here is my button that is supposed to open the dialog: 这是我应该打开对话框的按钮:
<button type="button" onClick="loadPreviewView()">Preview</button>
I do know that the loadPreviewView() function is being called, however the dialog box just isn't popping up. 我确实知道loadPreviewView()函数正在被调用,但是对话框不会弹出。 What am I missing?
我想念什么?
$("#loadPreviewDiv").click(function () {
$('#dialog').dialog({
title: "Dialog box",
height: 300,
modal: true,
open: function (event, ui) {
},
buttons: { "close": function() { $(this).dialog("close"); } }
});
});
Demo:
演示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.