首先,我对 JQuery 和 Web 技术总体上是新手。到目前为止,我一直在玩 node.js/expressjs/jade.js 和 JQuery 几周。
出于某种原因,我无法获得模态对话框的工作。以下代码显示按钮和按钮单击显示“对话框”。此对话框只是按钮下方的 div 元素,而不是按钮上方。最重要的是,您不能移动按钮,并且样式与 JQuery 示例中所示的样式不同。
http://jqueryui.com/demos/dialog/
有人可以善良并指出问题或复制粘贴工作示例。谢谢。
<html>
<head>
<title>Places Server</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.21/themes/base/jquery-ui.css" type="text/css" media="all"/>
<link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
jQuery(document).ready( function(){
jQuery("#myButton").click( showDialog );
//variable to reference window
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.dialog({ height: 350,
width: 400,
modal: true,
position: 'center',
autoOpen:false,
title:'Hello World'
//overlay: { opacity: 0.5, background: 'black'}
});
}
);
//function to show dialog
var showDialog = function() {
//if the contents have been hidden with css, you need this
$myWindow.show();
//open the dialog
$myWindow.dialog("open");
}
//function to close dialog, probably called by a button in the dialog
var closeDialog = function() {
$myWindow.dialog("close");
}
</script>
</head>
<body>
<input id="myButton" name="myButton" value="Click Me" type="button"/>
<div id="myDiv" style="display:none" class="ui-dialog ui-widget ui-widget-content ui-corner-all undefined ui-draggable ui-resizable">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span id="ui-dialog-title-dialog" class="ui-dialog-title">Dialog title</span></div>
<div id="dialog" class="ui-dialog-content ui-widget-content">
<p>I am a modal dialog</p>
</div>
</div>
</body>
</html>