I have just updated jQuery & jQuery UI to: jquery-1.9.0.min.js and jquery-ui-1.9.2.min.js
And... all my unobtrusive Ajax calls (Ajax.ActionLink, Ajax.BeginForm) stopped working properly - they open results in a new page instead of updating the existing div.
And I get this javascript error in Firebug when my page loads:
Code hasn't changed of course, just updated the jQuery scripts using Nuget.
Anyone experienced the same problem ??
The easiest way to fix problems with the breaking changes in jQuery(in my opinion) is to install the
jQuery.Migrate
package that enables you to use deprecated function calls that were removed in version 1.9.0 onwards. At least until the unobtrusive ajax plugin is updated by Microsoft.Also, it appears that the nightly build of the unobtrusive ajax plugin have updated the api calls. I haven't tested it yet but you may find out how to acquire it in the asp.net codeplex page.
UPDATE: The Unobtrusive Ajax and Validation Nuget packages were updated so the
jQuery.Migrate
package isn't needed anymore.Also need to do these fixes :
Update jQuery.Validation plugin (to fix this problem)
Also make these changes to the
jquery.unobtrusive-ajax.js
file (see here for Connect issue)Replace
With
https://stackoverflow.com/a/14354091/358906
Update: This issue has been fixed in the latest NuGet package. I've posted another answer to reflect this. https://stackoverflow.com/a/15539422/714309
In
jquery.unobtrusive-ajax.js
, find and replace these four lines:$("a[data-ajax=true]").live("click", function (evt) {
$(document).on("click", "a[data-ajax=true]", function (evt) {
$("form[data-ajax=true] input[type=image]").live("click", function (evt) {
$(document).on("click", "form[data-ajax=true] input[type=image]", function (evt) {
$("form[data-ajax=true] :submit").live("click", function (evt) {
$(document).on("click", "form[data-ajax=true] :submit", function (evt) {
$("form[data-ajax=true]").live("submit", function (evt) {
$(document).on("submit", "form[data-ajax=true]", function (evt) {
You can also generate a new
jquery.unobtrusive-ajax.min.js
using WebGrease. From the Command Prompt, change to your solution folder and enter this command (assuming your project folder is calledWeb
):.live()
has been deprecated since 1.7 and was officially removed in jQuery 1.9. Use.on()
instead as it is the preferred method of doing the same thing.Update the Microsoft jQuery Unobtrusive Ajax NuGet package to the latest version.
In Visual Studio, from the Tools menu, select Library Package Manager and then click Package Manager Console. At the prompt, type:
This issue was fixed in Microsoft jQuery Unobtrusive Ajax 2.0.30116.0 (Monday, February 18, 2013), which replaced the calls to the
.live()
method (deprecated in jQuery 1.7 and removed from jQuery 1.9) with the recommended.on()
method.