Anyhow, things have changed quite a bit since then and I immediately knew it would be great to have Intelisense working for jQuery! There are several steps involved though but through much trial & error I've finally got it working properly. Hopefully others will benefit from my efforts.
How Do You Know if jQuery Intellisense is Working?
And here's one where it is working:
In the second screenshot, notice that the first item is a single "$". This is positive! If you wanted to test it further, you could type a little more, like: $("div").
Something akin to the following should then appear in the pop-up menu:
Important Note: Every time I first load a project/solution into VS2008, the jQuery Intellisense does NOT work on the initial try!! I have to clear that menu, wait a few seconds and then try again. From then on it works perfectly, showing the single "$" as the first item in the pop-up menu.
Getting jQuery Intellisense Up & Running
- Ensure that VS2008 SP1 is installed. (Further info)
- Ensure that Hotfix KB958502 is installed. (Further info)
- Install the jQuery library into your project. It'll have a filename like "jquery-1.3.2.js".
- Install the jQuery Intellisense file into your project. It may very well have a filename like "jquery-1.3.2-vsdoc2.js" but must be renamed to be identical to the jQuery library name, plus "-vsdoc". Thus in this example, it must be renamed to "jquery-1.3.2-vsdoc.js".
- Provide a reference to the jQuery library. There are generally two ways to do this, both of which are described below.
Referencing the jQuery Library and the jQuery Intellisense File
I'm a big believer in:
- Organizing a project's files into as many sub-folders as makes sense.
- Separating programming code from markup code as much as possible.
You might be wondering why there's no reference to the jQuery Intellisense file? Well, as long as it follows the filename syntax shown in Step #4 above then it is automatically detected and loaded.
No jQuery Intellisense there!
The solution is very simple though. Just add a reference like this to the top of the file:
A little while ago I presented a way to programatically load jQuery entirely from server-side code. It does work and is powerful because a common server-side method could be built and then used in all of your projects. But jQuery Intellisense will not work using that approach; at least not with VS2008. Perhaps that will change in VS2010!