我在一张表上有一个@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>
}
据我所知,您的链接在<td>
中,您想隐藏包含该td的行。并且您将锚定对象存储在unapproveLinkObj
中
因此,隐藏包含unapproveLinkObj
对象的那一行。你可以试试
unapproveLinkObj.parents('tr').hide();
或者如果想刷新页面,你可以尝试
location.reload();
考虑到当用户单击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
}
if (data == '<%= Boolean.TrueString %>') {
// I want to hide the row here.....
$(".grtr").hide(); // access the row contents
}