我有下表,其中包含一个删除对象的ajax.actionlink: -
<tr id = @answer.AnswersID>
<td>
@Html.DisplayFor(modelItem => answer.Description)
</td>
<td>
@Html.DisplayFor(modelItem => answer.Answer_Description.description)
</td>
<td>
@{ string i = "Are uou sure you want to delete " + @answer.Description.ToString() + " ?";}
@Ajax.ActionLink("Delete", "Delete", "Answer",
new { id = answer.AnswersID },
new AjaxOptions
{
Confirm = i,
HttpMethod = "Post",
OnBegin = string.Format(
"disablelink({0})",
Json.Encode(answer.AnswersID)),
OnSuccess = string.Format(
"deleteconfirmation3({0})",
Json.Encode(answer.AnswersID))
})
</td>
</tr>}
以及以下OnBegin
&amp; OnSuccess
个脚本: -
function disablelink(rid) {
$('#' + rid).attr("disabled",true);}
function deleteconfirmation3(rid) {
$('#' + rid).remove();
jAlert(rid + ' Was Deleted Succsfully succsfully', 'Deletion Confirmation');}
我要做的是阻止用户点击删除按钮两次,但('#' + rid).attr("disabled",true);
不会阻止用户在系统处理第一个删除请求时点击删除链接“删除”链接仍将启用。
那么我在处理删除请求时如何取消激活整个表格行?
第二个问题: - 我如何将两个参数传递给我的java脚本函数,类似于: -
OnSuccess = string.Format(
"deleteconfirmation3({0}.{0})",
Json.Encode(answer.AnswersID,answer.Description))
因为Json.Encode只允许传递一个参数?
BR
答案 0 :(得分:0)
我遇到了同样的问题。
对于第二个问题,您可以这样做(查看OnComplete属性)
@Ajax.ActionLink(@"Show others", "ActionName", "ControllerName",
new { param1= Model.param1, param2= Model.param2 },
new AjaxOptions
{
UpdateTargetId = "idDivToUpdate",
HttpMethod = "POST",
InsertionMode = InsertionMode.InsertAfter,
OnFailure = "AjaxBoxVideoGalleryFailure('showOthersFg')",
OnBegin = "AjaxBoxVideoGalleryBegin('paramToJqueryFunction')",
OnComplete = string.Format("showArticlesNew(window.event ? event : null,'paramToJquery','OtherParameter',{0},1,3)", myC#Variable),
LoadingElementDuration = 250
},
new { @class = "cssClassToAssign", id = "idOfMyLink" })
对于第一个问题,我使用了切换方法,效果很好。
//use that line of code both in complete and failure for ajax call
function AjaxBoxVideoGalleryFailure(idbutton) {
$('#' + idbutton).toggle();
}
function AjaxBoxVideoGalleryBegin(idbutton) {
$('#' + idbutton).toggle();
}