我正在尝试在mvc 3应用程序的列表操作中显示删除链接上的模式确认对话框。
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$("#dialog-confirm").dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 180
});
});
$(document).delegate(".deleteLink", "click", function (e) {
e.preventDefault();
alert('test');
var $link = $(this);
var $dialog = $('#dialog-confirm')
.dialog({
autoOpen: false,
modal: true,
resizable: false,
height: 180,
buttons: {
'button text': function () {
alert("button"); //this is the button, do something with it :)
}
}
});
$dialog.dialog('open');
});
<div id="dialog-confirm" title="Delete the item?" >
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>This item will be deleted. Are you sure?</p>
这是链接
@Html.ActionLink("حذف", "Delete", "Need", new { id = item.NeedID }, new { @class = "deleteLink", title = "حذف" })
当我删除按钮选项时,它可以工作,但是当我添加它时,它不再显示 我做错了什么?
答案 0 :(得分:0)
很快就会看到 - 按钮似乎是一个数组。尝试粘贴文档中的示例:
... {
autoOpen: false,
modal: true,
resizable: false,
height: 180,
buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } } ]
}