views:

3462

answers:

6

I have been using jQuery IntelliSense in VS2008 and it has been great. Recently I added a reference to jQuery UI and since then, the jQuery IntelliSense has went away. I found that once you reference another .js file in your document, the IntelliSense goes away. Any way to avoid this?

+5  A: 

It's likely that there's a bug in one of the subsiquiently referenced JavaScript files. Open your JS file and once the "Updaing JavaScript Intellisense" has gone from the status bar of Visual Studio (there is a menu option which will force the JS intellisense to refresh, don't remember where it is, I just created a keyboard shortcut via the Tools -> Options -> Keyboard area) open up your Errors window and under the Warnings you should find the reason why the intellisense has failed to load.

It's generally a bug found when parsing one of the files but I have had stack overflows when I had a lot of files referenced.

Edit: You also should make sure you have this VS patch installed: http://code.msdn.microsoft.com/KB958502 and VS 2008 SP1 (install SP1 first!). Then you just need to have:

/// <reference path="/path/to/jquery-1.3.1.js" />

Ensure that you maintain the -vsdocs on the intellisense file and it will be automatically picked up (as long as it's in the same folder as the file you reference)

Slace
The error is "Error updating JScript IntelliSense: C:\Users\Brian\Documents\Visual Studio 2008\Projects\jQueryTest\jQueryTest\jquery-1.3.1-vsdoc.js: 'jQuery.support.htmlSerialize' is null or not an object @ 1418:4"The jscript files I am using are the jQuery and jQuery UI files from jquery.com
Brian David Berman
you're probably best to submit that as a bug report to MS then
Slace
I'm still unable to get this to work. Anyone out there able to use jQuery with jQuery UI w/ jQuery IntelliSense?
Brian David Berman
@Brian - I found your post when looking for a solution to the same problem. In my case, it turns out that I was also referencing other modules from jQuery UI. Perhaps you can check that you're only importing the js files you need?
Mark
What do you need that reference path for? I seem to have it working without that by creating a [dummy file](http://stackoverflow.com/questions/555269/adding-additional-js-files-breaks-jquery-intellisense/658546#658546)
Casebash
+11  A: 

If there are errors in any refernced files it will break intellisense for all files references from the same document. The next version of Visual Studio is going to be much more robust in this respect. I apologize directly for this fragility. We made some design decisions early on that we prevented us from making VS9 external references more robust.

In the meantime, use the following workaround. Install SP1 from the link Slace gave you. If you have a reference a file named .js and there is a file named -vsdoc.js in the same location, then JS intellisense will pick up the -vsdoc version. If that script is empty then it won't generate an error. Identify the jquery plugin that is causing intellisense generation to fail and place a -vsdoc version next to it. You won't get intellisense for UI, but you will still get jquery and other plugins that do work.

Anything you put in the vsdoc version will show up in intellisense. You could put spoofed versions of the data structures that you want to display in intellisense if you want to.

Alan Oursland
+7  A: 

The accepted answer helped me fix this issue but didn't resolve the problem. I installed the hotfix: http://code.msdn.microsoft.com/KB958502 but was still receiving an error.

Error:

Error updating JScript IntelliSense: D:\Dev\Test\Scripts\jQuery-1.3.2-vsdoc.js: 'jQuery.support.htmlSerialize' is null or not an object @ 1430:4

It appears the addition of the follwing file without the appropriate -vsdoc.js file causes the above issue.

<script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>

I added an empty file "jquery-ui-1.7.custom.min-vsdoc.js" to my scripts folder and the Jscript Intellisense issue went away.

Rick Hochstetler
This is completely ridiculous that this works as a solution, but it does :\ WTF Microsoft!!!
Josh
Unbelievable, this is so silly.
SoftwareGeek
+1  A: 

I solved this per the advice above with a minor extension: the trick for me was to add a reference on my page to both my jqueryui.com library AND to the blank -vsdoc.js version of the file I created:

<script type="text/javascript" src="../../Scripts/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery-ui-1.7.2.custom.min-vsdoc.js"></script>

Hope this helps!

vealer
This second link should only be necessary if you haven't installed the [patch](http://code.msdn.microsoft.com/KB958502)
Casebash
+2  A: 

I'd like to present a slightly better solution. A few months ago I tackled this problem and created a very basic vsdoc file for jQuery UI. Here's the link to the blog post (which has the file for download).

DevTheo
+1  A: 

Great, the tweak is by creating an empty *-vsdoc.js file for each troublesome *.js files.

I found this error caused by anonymous function e.g. like this:

(function($) {
    $.anything...;
})(jQuery);

Hope this caused will help somebody creating the http://code.msdn.microsoft.com/KB958502 and JScript IntelliSense Team.

CallMeLaNN