1

So, i want to show a pop up when deleting a row from my table, so this is my action link :

  <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
  <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
  <script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>

@Html.ActionLink("Delete", "Delete", new { id=item.cin  },new { @class = "delete-logo"  ,@pkNo=item.cin})
 <div id="confirmDialog" title="Warning"></div>

my script :

<script type="text/javascript">

$(document).ready(function () {
    buttonizeALL();
    setLinks();
});

function buttonizeALL() 
{        
    $(".delete-logo").button();
}

function setLinks() 
{
    //delete person
    $(document).ready(function () {
        $(".delete-logo").live("click", function (e) {
            e.preventDefault();

            var pkNo = $(this).attr("pkNo");


            $("#confirmDialog").dialog({
                resizable: false,
                height: 200,
                width: 300,
                modal: true,
                buttons: {
                    "Yes": function () {
                        $(this).dialog("close");
                        var rowNo = '#row-' + pkNo;
                        var url = '/Subscribers/Delete/' + pkNo;
                        $.ajax({
                            type: "Delete",
                            url: url,
                            data: {},
                            cache: false,
                            dataType: "json",
                            success: function () {

                                $(rowNo).animate({ opacity: 0.0 }, 400, function () {
                                    $(rowNo).remove();
                                });

                            },

                            error: function (jqXHR, exception) {
                                alert('Uncaught Error.\n' + jqXHR.responseText);
                            }

                        }); //end ajax call

                    }, // end of yes button
                    "No": function () {
                        $(this).dialog("close");
                    }
                } //end buttons
            }); //end modal 
        });      //end delete

    });
} //end setLinks

my problem is the pop up doesn't work, and when i used my script without the pop up it works, so please if some one have any idea i will be very appreciated.

4

2 回答 2

1

首先,不要再使用“live”命令了。那已被弃用以代替“on”命令。也不需要在 setLinks 函数中使用 $(document).ready 。由于它是一个独立的函数(不是自执行的),它只放入内存中,直到您在 doc.ready 函数中调用它时才被调用。

于 2013-04-28T13:15:27.400 回答
1

是您在 jsFiddle 中整理的示例,即我已将 setLinks() 代码移至 document.ready() 函数中。

$(document).ready(function () {
    buttonizeALL();
    setLinks(); // removed this
});

我还用它将呈现的锚标记替换了 ActionLink。这是使用 Jquery 1.8.3 和 jQuery UI 1.9.2。弹出式接缝可以正常工作。

于 2013-04-28T13:26:22.057 回答