javascriptjqueryasp.net-mvc-3razorjquery-2.0

ASP.NET Code generated by Ajax.ActionLink stopped working after Upgrading to JQuery 2.0.1


I have an ASP.NET MVC3 app that I have upgrade to JQuery 2.0.1, unfortunately this has had some unpleasant side effects. (More info here)

Currently I have only one outstanding issue: The HTML link generated by @Ajax.ActionLink no longer calls the appropriate js code, but instead is treated as a regular link by the browser.

The page in question contains the following js files:

<script src="/Scripts/jquery-2.0.1.min.js" type="text/javascript"></script>
<script src="/Scripts/modernizr-2.6.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui-1.10.3.min.js" type="text/javascript"></script>

<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript">script>
<script src="~/Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript">   </script>

I have had to manually update the jquery.unobtrusive-ajax.min.js file to resolve another issue (replace live by on).

The Ajax.ActionLink looks as follows:

@Ajax.ActionLink("Delete", "Delete", "InputResources",
                new { id = Model[i].ID },
                new AjaxOptions
                {
                    HttpMethod = "DELETE",
                    Confirm = "Are you sure you want to delete?",
                    OnComplete = "window.location.href='/Projects/InputResources/" + ViewBag.ProjectID + "'"
                })

The HTML generated seems to look sound:

<a href="/InputResources/Delete/5" data-ajax-method="DELETE" data-ajax-confirm="Are you sure you want to delete?" data-ajax-complete="window.location.href='/Projects/InputResources/2'" data-ajax="true">Delete</a>

Can anyone suggest what js files and how I need to modify in order to get this link working correctly again?


Solution

  • Here is what solved it for me:

    This will update your jquery validation script to latest version:

    PM> Install-Package jQuery.Validation 
    

    This will update your jquery unobtrusive validation script to latest version:

    PM> Install-Package jQuery.Ajax.Unobtrusive
    

    Make sure both are included in your page after jquery library, it will not work if you don't do this.