1

我正在尝试在 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 = "حذف" })

当我删除按钮选项时它可以工作,但是当我添加它时,它不再出现在我做错的地方?

4

1 回答 1

0

快速浏览一下 - 按钮似乎是一个数组。尝试粘贴文档中的示例:

    ... {
        autoOpen: false,
        modal: true,
        resizable: false,
        height: 180,
        buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } } ]
   }
于 2013-06-18T20:58:39.740 回答