我是JQueryUI的新手,虽然我有一个对话框可以工作,但它不会按我想要指定的大小打开。为什么在定义对话框时设置宽度和高度不影响对话框的初始大小?我如何使它600乘以500 px?
下面是定义对话框的div:
<div id="dialog-form" title="Create Appointment">
<form> . . . </form>
</div>
下面是创建对话框的JavaScript:
$(function() {
$("#dialog-form").dialog({
autoOpen: false,
maxWidth:600,
maxHeight: 500,
width: 600,
height: 500,
modal: true,
buttons: {
"Create": function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
}
});
以及定义打开它的按钮的JavaScript:
$("#create-appt")
.button()
.click(function() {
$("#dialog-form").dialog("open");
});
});
编辑:
我现在看到了这个问题:如果我没有使用--app=...
命令行选项在Google中运行它,那么它就不会重新加载整个应用程序了。
发布于 2011-04-11 19:31:21
问:为什么在定义对话框时设置宽度和高度不影响对话框的初始大小?
答:确实是..。您使用的是什么浏览器和jQuery的版本。
我把你的代码从上面剪切/粘贴到一个小样本中,它工作得很好.我把完整的样品贴在下面,你可以在你的头上试试。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery UI Example Page</title>
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.11.custom.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.11.custom.min.js"> </script>
<script type="text/javascript">
$(document).ready(function () {
$(function() {
$("#dialog-form").dialog({
autoOpen: false,
maxWidth:600,
maxHeight: 500,
width: 600,
height: 500,
modal: true,
buttons: {
"Create": function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
},
close: function() {
}
});
});
$("#create-appt")
.button()
.click(function() {
$("#dialog-form").dialog("open");
});
});
</script>
</head>
<body>
<h1>test</h1>
<div id="dialog-form" title="Create Appointment">
<p> this is my test </p>
</div>
<input type="button" id="create-appt" value="test"/>
</body>
</html>
发布于 2011-04-11 19:19:45
我不知道具体发生了什么,但是您可以稍微修改代码,它会产生您期望的结果:
您可以在onclick事件上设置以下选项,而不是使用autoOpen:
$("#create-appt")
.button()
.click(function() {
$("#dialog-form").dialog({width: 600,height:500});
});
我希望这能帮上忙,马塞洛·维斯马利
https://stackoverflow.com/questions/5625835
复制相似问题