0

テーブルに@Html.Actionlink(....)があります。そして、確認のためにjqueryダイアログを表示しています。すべてが正常に動作します。しかし、ユーザーが「続行」をクリックした後、リンクアクションが「true」を返した場合に行を非表示にしたい。

私は次のjqueryコードを使用しています。

var unapproveLinkObj;
    // delete Link
    $('.unapprove-link').click(function () {
        unapproveLinkObj = $(this);  //for future use
        $('#unapprove-dialog').dialog('open');
        return false; // prevents the default behaviour
    });

    $('#unapprove-dialog').dialog({
        autoOpen: false, width: 400, resizable: false, modal: true, 
        buttons: {
            "Continue": function () {
                $.post(unapproveLinkObj[0].href, function (data) {  //Post to action
                    if (data == '<%= Boolean.TrueString %>') {

                      // I want to hide the row here.....

                    }
                    else {
                        //Display Error
                    }
                });
                $(this).dialog("close");
            },
            "Cancel": function () {
                $(this).dialog("close");
            }
        }
    });

ページを更新する方法はありますか、または更新せずに行を非表示にする方法はありますか.. ??

編集:これがHTMLです

 @foreach (var i in Model)
{
    <tr class="grtr">
        <td>@i.CustomerName</td>
        <td>@i.BranchName
        <br />
        @i.Address
        </td>

        <td>@i.PostCode</td>
        <td>@i.City</td>
        <td>@i.Telephone</td>


            @if (!string.IsNullOrEmpty(i.Latitude))
            {
                <td>Yes</td>
            }
            else
            {
                <td>No</td>
            }
            @if (!string.IsNullOrEmpty(i.Longitude))
            {
                <td>Yes</td>
            }
            else
            {
                <td>No</td>
            }

        <td>@i.IsClaimed</td>
        <td>@Html.ActionLink("Approve", "Approve", "Location", new { id = @i.ID }, new 
       {
           @class="unapprove-link"

       })</td>
        <td>
        @Html.ActionLink("Delete", "Delete", "Location", new { id = @i.ID }, new {@class="delete-link"})

       </td>
        <td>Map</td>
    </tr>
}
4

3 に答える 3

0

continueユーザーが「試してみる」をクリックしてもエラーがない場合は、以下の条件に該当することを考慮します。

if (data == '<%= Boolean.TrueString %>') {

       // I want to hide the row here.....
       $("table").hide(); // table is the id or class to access the table contents    

}
于 2012-08-22T09:05:07.483 に答える
0

私が理解しているように、あなたのリンクはaの中に<td>あり、あなたはそのtdを含むその行を非表示にしたいです..そしてあなたはあなたのアンカーオブジェクトをに保存していますunapproveLinkObj

したがって、unapproveLinkObjオブジェクトを含むその行を非表示にします。あなたが試すことができます

unapproveLinkObj.parents('tr').hide();

または、ページを更新したい場合は、試すことができます

location.reload();
于 2012-08-22T08:54:56.390 に答える
0
if (data == '<%= Boolean.TrueString %>') {

       // I want to hide the row here.....
       $(".grtr").hide(); // access the row contents    

}
于 2013-03-02T04:40:24.237 に答える