【发布时间】:2014-12-08 09:55:20
【问题描述】:
我正在尝试在我的网站中实现一个 JQuery 对话框,以询问用户是否真的想删除一个项目。
但下面的代码不起作用,它只是不显示对话框 onclick。 这是我的代码:
脚本
$(function() {
$( "#delete" ).dialog({
autoOpen: false,
modal: true,
buttons: {
DELETE: function() {$(this).dialog("close");},
CANCEL: function() {$(this).dialog("close");}
},
});
$( ".delete-action" ).click(function() {
$( "#delete" ).dialog( "open" );
});
});
HTML
<div id="delete" title="Delete" style="display: inline-block">
</div>
<button id="pass" class="delete-action"><img src="$base/includes/img/icons/16/trash.png" style="width: 16px; height: 16px;"/></button>
includes + css
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
.ui-widget-header,.ui-state-default, ui-button{
background:#b9cd6d;
border: 1px solid #b9cd6d;
color: #FFFFFF;
font-weight: bold;
}
</style>
这里是 jsfiddle 的链接:Code
任何人都可以提供一些帮助,因为我不知道如何解决它:(我在谷歌和 StackOverflow 上搜索了很多,因为有很多类似于我的问题,但没有一个解决方案有效对我来说
感谢您的帮助,问题已解决,提供的代码是最新的
【问题讨论】:
-
我不知道这是否是您的问题的原因,但您需要用逗号分隔每个按钮:
DELETE: function() {$(this).dialog("close");}, CANCEL: function() {$(this).dialog("close");} -
不能解决问题 :( 但不将它们分开肯定是错误的