VB Magic

2013/01/30

MVC4 Templates and latest nuget javascript updates causes error in jquery.unobtrusive-ajax.js

Filed under: .NET, ASP.NET MVC — Tags: , , , , , — vbmagic @ 2:21 pm

I updated the nu-get packages for my newly created MVC4 website and I started to get lots of JavaScript errors as shown below.

Error Dialogue

It took a bit of web searching but I found a solution. A feature used in the MVC templates has been removed (Previously it was deprecated) from the latest version of JQuery (1.9)

I found a solution to this on Stack Overflow

Basically you need to add the jQuery.Migrate package to your solution via the package manager:

PM> Install-Package jQuery.Migrate

And then modify the BundleConfig.vb found in the App_Start folder in you project so that it references the jQuery.Migrate package.

Public Class BundleConfig
    ' For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
    Public Shared Sub RegisterBundles(ByVal bundles As BundleCollection)
        bundles.Add(New ScriptBundle("~/bundles/jquery").Include(
                   "~/Scripts/jquery-{version}.js",
                   "~/Scripts/jquery-migrate-1.0.0.js"))

This should fix the problem until the templates get updated.

1 Comment »

  1. After meeting further issues, I’d recommend not updating jQuery until things settle down.

    Comment by vbmagic — 2013/01/30 @ 3:45 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: