<%: Ajax.ActionLink("View Code Status", "GetCodes", "BvIndex",
new { id = o.Id },
new AjaxOptions { UpdateTargetId = count.ToString() },
new { @id = "h" + count.ToString()}) %>
I want to hide the link after the ajax call is made. I tried doing it onsuccess and oncomplete methods but i was not able to do it. Any solution for this.
This is the way which i tried onsuccess, i was able to hide it but i am getting an error.
<%: Ajax.ActionLink("View Code Status", 开发者_运维问答"GetCodes", "BvIndex",
new { id = o.Id },
new AjaxOptions {
OnSuccess = "functionhide("+count+")",
UpdateTargetId = count.ToString()
},
new { @id = "h" + count.ToString()})%>
onsuccess function
function functionhide(count) {
$("#h" + (count)).hide();
};
This is working fine but,I am getting an error saying,
Microsoft JScript runtime error: 'b' is null or not an object
Try like this:
<%= Ajax.ActionLink(
"View Code Status",
"GetCodes",
"BvIndex",
new { id = o.Id },
new AjaxOptions {
OnSuccess = "functionhide",
UpdateTargetId = count.ToString() // <-- Warning you are probably having invalid markup as ids cannot start with a number
},
new {
id = "h" + count.ToString()
}
) %>
and then:
function functionhide() {
$(this).hide();
}
Simple solution is to use -
OnComplete="javascript:this.style.display='none'"
e.g.
@Ajax.ActionLink(
"Hide button before ajax",
"myAction",
new AjaxOptions { OnComplete="javascript:this.style.display='none'" }
)
I found this Stack Overflow post that might help you out... they noted receiving the same error message and making the OnSuccess
value an anonymous function seemed to fix it.
精彩评论