Rich IntelliSense for jQuery

Rich IntelliSense for jQuery

  • Comments 73

Update: A new Hotfix is availble to complement this file.

A while back we updated VS2008 IntelliSense to not fail when referencing jQuery.  However, getting IntelliSense for chained calls and rich summary/parameter hints still required adding special comments to a few thousand lines of jQuery.  If you didn't have the time, you could download such a file from friendly members of the community such as James and Brennan.

As part of our new partnership with jQuery, yesterday we announced the availability of the official IntelliSense documentation file.  As you can see, our friends at jQuery have added a new download link for Visual Studio at http://docs.jquery.com/Downloading_jQuery#Download_jQuery.

image

You can also download the file directly from http://code.jquery.com/jquery-1.2.6-vsdoc.js.  As you might guess, this documentation file corresponds with the latest version of jQuery (which is currently 1.2.6).  While this file has a "js" extension, it's really just a documentation file.  You do not want to run this file in the browser.

How do I use this file (today)?

If you're inside an ASPX page, you will need to add the following lines of code into (normally) the head of your page:

image

Why do we have a server-side conditional statement?  IntelliSense disregards conditional statements of this type, and thus loads the "vsdoc" file (overriding the normal one).  At runtime the if (false) statement will ensure it this documentation file is not rendered (and executed) as script.  This trick allows the "switching" behavior you want.

If you're in a JavaScript file, use the normal file reference syntax to refer to the "vsdoc" file.

image

There's no need for tricks here since this comment is only meaningful to IntelliSense.

How do I use this file (in the near future)?

The ideal user experience should be one where you do not need special tricks as mentioned above.  Really, you shouldn't need to mention the "vsdoc" file name at all.  To that end, we plan on releasing a Hotfix that will enable this (stay tuned!).  Given normal references such as...

image image

...IntelliSense will opportunistically search for "jquery-1.2.6-vsdoc.js" and load that file instead.  Generally, given script name "x", IntelliSense will opportunistically search for "x-vsdoc.js".  If not found, it will then search for "x.debug.js".  You just need to make sure to place your "vsdoc" file next to the normal file.  Note, if you use jquery-1.2.6.min.js, you may need to rename the file to match the search pattern.

What are the advantages of this file?

One unique benefit of the file we have released is that it supports and understands jQuery plug-ins.  For example, given the plug-in below...

image

...you would see "myplugin" show up in IntelliSense.

image

We've noticed a few plug-ins do not work, and commonly this is because there is an IntelliSense incompatibility issue with the plug-in itself (as opposed to the jQuery documentation file).

Hope this helps!

Jeff King
Program Manager
Visual Studio Web Tools

Leave a Comment
  • Please add 6 and 2 and type the answer here:
  • Post
  • It looks like many of you have already noticed that there's an official Visual Studio autocomplete file

  • Last week was our big PDC conference, and I've been busy catching up back at work this week.  I

  • Last week was our big PDC conference, and I've been busy catching up back at work this week.  I'm

  • FYI: Wrap it in a <asp:Literal runat="server" Visible="false"> if you want it to work in Master Pages or other places where inline code blocks aren't supported.

  • JQuery Intellisense in Visual Studio 2008 - Tip if it's not working in MVC

  • In MVC projects jQuery intellisense doesn't show up if I reference the script files with an absolute root path like "/scripts/jquery-1.2.6-vsdoc.js". However, if I reference it with the tilda relative root it does work "~/scripts/jquery-1.2.6-vsdoc.js"

  • I'm having the same problem than Marcus except the tilda trick doesn't even work for me.

    Actually I'm only getting intellisense for standard js functions and my local functions.

    I don't get any intellisense for Ajax either.

    I'm using the standard MVC template and am declaring my scripts in my master page as follows:

    <script src="../../Scripts/jquery-1.2.6.js" type="text/javascript"></script>

       <% if (false) { %>

           <script src="../../Scripts/jquery-1.2.6-vsdoc.js" type="text/javascript"></script>

       <% } %>

       <script src="../../Scripts/jquery.color.js" type="text/javascript"></script>    

       <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>

       <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>

    </head>

    Any idea?

  • So I'm using the Google provided method of including jQuery in my pages:

    <script type="text/javascript" src="http://www.google.com/jsapi"></script>

    <script type="text/javascript">google.load("jquery", "1");</script>

    At the moment I am just specifying the latest major version of jQuery to include which just happens to be 1.2.6.

    [quote]

    Generally, given script name "x", IntelliSense will opportunistically search for "x-vsdoc.js".

    [/quote]

    So given that I am not referencing jquery-1.2.6.js, I take it there will be no IntelliSense support when including jQuery with the Google provided method?

  • I have all my js in an external js file. Is there any way I can take advantage of this with an external js file?

    I assume no, in any case great work this is a good thing.

  • Patrick:

    Check to see if you have SP1 installed. I had the same issue with jQuery. I thought I installed it on my work machine but forgot about it. Once I did intellisense started working.

  • Here is a small post on Jquery which is a far better alternative to Aspnet Ajax.Its a small JavaScript

  • 本文文源来自ScottGu's Blog,我将其中的内容摘录并翻译。文章内容是近期精彩博文推荐,内容涵盖ASP.NET AJAX, jQuery, ASP.NET MVC及Silverlight。相信其中很多文章对您非常有用。

  • Last week was our big PDC conference, and I&#39;ve been busy catching up back at work this week.&#160;

  • Last week I mentioned we would be releasing a Hotfix to accompany our new jQuery VSDoc file . This Hotfix

  • Jeff King just announced the release of a patch for Visual Studio 2008 that enables the IDE to find the

Page 2 of 5 (73 items) 12345