Derik Whittaker

Syndication

News


Adding JQuery UI to MVC 3 Application causes a JScript Runtime exception

Today I added a reference to jQuery UI via Nuget to the rewrite of the Dimecasts.net website and as soon as I launched the site locally I was presented with the following dialog:

image

Now given the fact that the ONLY change to my code base was adding the scripts to my scripts folder as well as adding the 2 lines to my _Layout.cshtml file which includes the jQuery in the application as below I knew the error had to be w/ the adding of the script tags.

image

In order to prove my theory I simply removed the script tag which included jquery-ui-1.8.16 and restarted the site.  Sure enough everything worked just fine.  When I took a step back and better studied the error it made sense to me that jquery-ui MUST be after the jQuery script tag. So I moved the script tag to the end of the list as below and restarted the site.

image

Sure enough all is right with the world and I no longer have any runtime JScript engine exceptions.  Now it is time to make use of the JQuery UI stuff.

Hope this helps someone in the future.

Till next time,


Posted 09-10-2011 6:08 AM by Derik Whittaker

[Advertisement]

Comments

Simon wrote re: Adding JQuery UI to MVC 3 Application causes a JScript Runtime exception
on 09-11-2011 7:05 PM

Seriously? You decided to write a blog post about that? :)

Anyway, it occurred because Nuget was messing up the order or it was a manual error?

David Clarke wrote re: Adding JQuery UI to MVC 3 Application causes a JScript Runtime exception
on 09-13-2011 7:15 PM

Not wishing to be a suck up but posts like this can be enormously useful once indexed and searchable. I have had an occasional head scratcher that ultimately ended in a "Doh" because I had overlooked something simple.

artur02 wrote re: Adding JQuery UI to MVC 3 Application causes a JScript Runtime exception
on 09-17-2011 2:39 PM

You should always include jQuery plugins/widgets after the jQuery library as they extend the jQuery or jQuery.fn objects. So if there is no jQuery object and you call e.g. jQuery.fn, jQuery is undefined and you get the error above. The same is true for dependent plugins.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)