【问题标题】:jquery ui dialog doesn't work with buttonsjquery ui 对话框不适用于按钮
【发布时间】:2013-06-14 10:09:57
【问题描述】:

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

当我删除按钮选项时它可以工作,但当我添加它时,它不再显示 我哪里做错了?

【问题讨论】:

  • 起初我使用 .live 选项,但它是一样的
  • 嗨,我也在努力。这对你有用吗?请问我需要一些帮助。

标签: asp.net-mvc-3 jquery-ui modal-dialog confirmation


【解决方案1】:

一目了然 - 按钮似乎是一个数组。尝试粘贴文档中的示例:

    ... {
        autoOpen: false,
        modal: true,
        resizable: false,
        height: 180,
        buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } } ]
   }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    • 2010-12-20
    • 2010-10-31
    • 2011-02-01
    相关资源
    最近更新 更多