Javascript jQuery对话框工作不正常
我有以下脚本:Javascript jQuery对话框工作不正常,javascript,jquery,Javascript,Jquery,我有以下脚本: <script type="text/javascript"> $( "#addLocation" ).dialog({ autoOpen: false, modal: true, height: 700, width: 550, buttons: { "Add Location": function() { document
<script type="text/javascript">
$( "#addLocation" ).dialog({
autoOpen: false,
modal: true,
height: 700,
width: 550,
buttons: {
"Add Location": function() {
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
</script>
<script type="text/javascript">
function showLocationDialog() {
$("#addLocation").dialog("open");
}
</script>
<div id="addLocation" style="display:none;">
<form action="" method="post" name="mapform">
<input type="text" name="name" />
<input type="submit" />
</form>
</div>
<button onclick="javascript:showLocationDialog();">Add an address</button>
$(“#添加位置”)。对话框({
自动打开:错误,
莫代尔:是的,
身高:700,
宽度:550,
按钮:{
“添加位置”:函数(){
document.forms[“mapform”].submit();
},
取消:函数(){
$(此).dialog(“关闭”);
}
},
});
函数showLocationDialog(){
$(“#添加位置”)。对话框(“打开”);
}
添加地址
按钮无法打开对话框,我无法理解原因。。有人能帮忙吗
谢谢,1-将.dialog()
初始化放在一个文件夹中
2-删除按钮值后面的多余逗号:
buttons: {
"Add Location": function() {
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
}, <-- remove this, causes IE to spontaneously combust
按钮:{
“添加位置”:函数(){
document.forms[“mapform”].submit();
},
取消:函数(){
$(此).dialog(“关闭”);
}
},1-将.dialog()
初始化放入一个对话框中
2-删除按钮值后面的多余逗号:
buttons: {
"Add Location": function() {
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
}, <-- remove this, causes IE to spontaneously combust
按钮:{
“添加位置”:函数(){
document.forms[“mapform”].submit();
},
取消:函数(){
$(此).dialog(“关闭”);
}
},等待DOM准备就绪
将.dialog()
代码粘贴到$(文档).ready()
或$()
块中,等待DOM准备就绪
将您的.dialog()
代码粘贴到$(文档).ready()
或$()
块中另一件要尝试的事情
从addLocation div中删除display:none
css。一旦在文档上初始化,该对话框将负责隐藏所有内容。准备好了吗?另一件要尝试的事情
从addLocation div中删除display:none
css。一旦在文档上初始化,对话框将负责隐藏所有内容。ready这不是一个好主意;内联css在dom准备好之前隐藏表单-这有两个优点,首先用户看不到某个东西,然后看到它消失,这很混乱,浏览器不会浪费资源在加载时渲染,然后在dom准备好时重新渲染,dialog()将其全部隐藏。这不是一个好主意;内联css在dom准备好之前隐藏表单-这有两个优点,首先用户看不到某个东西,然后看到它消失,这是令人困惑的,浏览器不会浪费资源在加载时渲染,然后在dom准备好时重新渲染,dialog()会将其全部隐藏。