Problem:
The dialog div is displaying without the buttons being pressed, and does not appear as an overlay when I press them. I'm tearing my hair out, so thanks in advance.
对话框div在没有按下按钮的情况下显示,并且在按下它们时不会显示为叠加。我正在撕掉我的头发,所以提前谢谢。
Code:
Includes:
包括:
<script src="js/jquery-1.5.1.min.js"></script>
<script src="js/ui/jquery.ui.core.js"></script>
<script src="js/ui/jquery.ui.widget.js"></script>
<script src="js/ui/jquery.ui.position.js"></script>
<script src="js/ui/jquery.ui.autocomplete.js"></script>
<script src="js/ui/jquery.ui.dialog.js"></script>
Css:
CSS:
<link rel="stylesheet" type="text/css" href="css/jquery.ui.autocomplete.
<link rel="stylesheet" type="text/css" href="css/jquery.ui.all.
<link rel="stylesheet" type="text/css" href="css/jquery.ui.theme.
<link rel="stylesheet" type="text/css" href="css/jquery.ui.dialog.css" />
Buttons: <a class="phoneadder">Stuff</a>
按钮:东西
Scripts:
脚本:
<script>
$( "#dialog-form" ).dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true
}
);
$( ".phoneadder" ).click(function() {
$( "#dialog-form" ).dialog( "open" );
return false;
});
</script>
Dialog:
对话:
<div id="dialog-form" title="Create new phone">
<p>All form fields are required.</p>
<form>
<fieldset>
...some html here
</fieldset>
</form>
</div>
4 个解决方案
#1
1
Try putting your jQuery code in the $(document).ready
function like this:
尝试将jQuery代码放在$(document).ready函数中,如下所示:
$(document).ready(function () {
/// your code here
});
#2
2
Place the initializer in your document.ready, or as shorthand:
将初始化程序放在document.ready中,或者作为简写:
$(function() { $("#dialog-form").dialog(autoOpen... ); } );
Alternatively, make sure your scripts are run after the div is created, so like, in the footer.
或者,确保在创建div之后运行脚本,就像在页脚中一样。
#3
1
Try this,
尝试这个,
$(function()
{
$( ".phoneadder" ).click(function() {
$( "#dialog-form" ).dialog({
height: xxx,
width: xxx,
modal: true
});
return false;
});
});
#4
0
Why don't you just put the dialog function in the click event handler?
你为什么不把对话功能放在click事件处理程序中?
<script>
$(function()
{
$( ".phoneadder" ).click(function() {
$( "#dialog-form" ).dialog({
height: 300,
width: 350,
modal: true
});
return false;
});
});
</script>
#1
1
Try putting your jQuery code in the $(document).ready
function like this:
尝试将jQuery代码放在$(document).ready函数中,如下所示:
$(document).ready(function () {
/// your code here
});
#2
2
Place the initializer in your document.ready, or as shorthand:
将初始化程序放在document.ready中,或者作为简写:
$(function() { $("#dialog-form").dialog(autoOpen... ); } );
Alternatively, make sure your scripts are run after the div is created, so like, in the footer.
或者,确保在创建div之后运行脚本,就像在页脚中一样。
#3
1
Try this,
尝试这个,
$(function()
{
$( ".phoneadder" ).click(function() {
$( "#dialog-form" ).dialog({
height: xxx,
width: xxx,
modal: true
});
return false;
});
});
#4
0
Why don't you just put the dialog function in the click event handler?
你为什么不把对话功能放在click事件处理程序中?
<script>
$(function()
{
$( ".phoneadder" ).click(function() {
$( "#dialog-form" ).dialog({
height: 300,
width: 350,
modal: true
});
return false;
});
});
</script>