I want to remove the Unobstrusive microsoft ajax @Ajax.ActionLink bind after click.
something like this:
.cshtml :
@Ajax.ActionLink("Edit", "EditDeliveryZones", new { idConnection = ViewBag.idConnection }, new AjaxOptions() { UpdateTargetId = "EditDeliveryZones" }, new { @class = "ajaxdialogopen" })
JavaScript:
$('.ajaxdialogopen').one('click', function (event) {
$(this).off('click'); // THIS DOESNT WORK
this.onclick = null; // THIS DOESN't WORK EITHER
}
Thanks!
How about putting something like this in your handler:
$(this).removeAttr('data-ajax');
I believe data-ajax
is the attribute that the live handler triggers on, so removing it from the link should prevent it from being treated as an ajax link anymore.
6
You might try something like
$('.ajaxdialogopen').click( function( event ) {
(event.preventDefault) ? event.preventDefault() : event.returnValue = false;
});
1
After reading microsoft and jquery libraries, it uses LIVE, which goes against the selector and not the element. So making the selector not match (aka removing the class) makes the event not trigger anymore.
Valid reason to of why live is deprecated … hope microsoft update it’s libraries soon.
5