JScript IntelliSense: Working with jQuery

JScript IntelliSense: Working with jQuery

Rate This
  • Comments 51

We have good news for jQuery fans.  The hotfix we released today fixes a bug in IntelliSense where it would fail with jQuery.  Any page with jQuery should just work now.  While experimenting with this new-found functionality today, I found annotating the library with a few XML Doc Comments really made a big difference.  The key is to add a return type of "jQuery" like this:

doc comments

Here's some jQuery chaining with IntelliSense:

completion list

tooltip

There were only a few functions that (due to the way they were declared) were not able to be annotated.  Special thanks to Brennan where I borrowed the comments from.  If anyone will be making a fully annotated version of jQuery, I'd be happy to post a link to it from here.

Jeff King
Program Manager
Visual Studio Web Tools

Leave a Comment
  • Please add 4 and 7 and type the answer here:
  • Post
  • We are working on ExtJS support right now. We haven't identified the problem yet, but looks like it is related to our simulated DOM. We will post as soon as we get it working (or if we cannot get it working).

  • Hi Jeff, this is really cool.  Starting with your example, I went through and <a href="http://lancefisher.net/blog/archive/2008/02/12/intellisense-for-jquery-in-visual-studio-2008.aspx">commented the jQuery library</a>.  I added comments for most everything, but there are still a few gaps.  You can download the .js from my blog.

  • Thanks for the quick answer. Btw, as an only semi-related sidenote, I'm quite enjoying the increased updates and transparency when it comes to VS2008, as opposed to what we had during the 2003 and 2005 days. Keep it up!

  • "@Mike : What's the disadvantage of having the OPTION to do this? For some development teams it might make sense to have a dev version of the library with comments for intellisense support. You could always change refs to packed or gzipped version for deployment."

    Sure some will do it, but that's not my point. It's the IDEA that is backwards, USERS adding comments to LIBRARIES they USE just to support their IDE. I hope the Open AJAX alliance will come up with a solution for this soon. Some kind of standard hooks EVERY IDE can use.

  • "However, it's technically a Sun trademark (see http://www.sun.com/suntrademarks/index.jsp) and--as an employee of another large software company--I just try to be careful."

    Amazing, I thought Netscape developed it? How did Sun get the trademark? Anyway, I never liked the term JScript either (also easy to confuse with JScript.NET), but at least now we know why you guys do it.

  • @Mike : Very good point about a possible standards hook. I had not looked into the Open AJAX Alliance previously, so your comment got me looking at it. Thanks

    For now though, I don’t think it’s necessarily a problem for users to put effort in to get intellisense support if they want it (I won’t, just thinking some teams will). This isn’t an exact parallel, but jQuery itself uses some custom selectors which aren't part of a standard, but are included because they are useful right now: http://docs.jquery.com/DOM/Traversing/Selectors#Custom_Selectors

  • Wikipedia has a little bit of history about Java/Javascript/JScript/ECMAScript:

    http://en.wikipedia.org/wiki/JavaScript

    http://en.wikipedia.org/wiki/ECMAScript

    The initial version of JScript was fairly different from the initial version of Javascript. At some point, a standard named ECMAScript was written and both implementations now conform to that.

  • 一週間近く遅れていますが、VS 2008 で適用できるホットフィックスが登場しています。 Web デザイナ周りのパフォーマンス改善やフィックスです。 詳しい内容等は、 ScottGu's Blog を翻訳している

  • Wonderful news for all jQuery-Fans like me. Thanks a lot...

  • JQuery IntelliSense in Visual Studio 2008

  • I've just put together a tool that reflects over the JQuery API and uses the published JQuery XML documentation to build up a stub file containing intellisense comments for JQuery. I've blogged about how you can use a stub like that to override the real JQuery with annotated stubs for intellisense here: http://blogs.ipona.com/james/archive/2008/02/15/JQuery-IntelliSense-in-Visual-Studio-2008.aspx

    For a number of reasons to do with how JQuery's implemented, this approach seems to be the best way to get good quality intellisense throughout JQuery's API. And now that VS2008 intellisense keeps working even when it comes across the jQuery sourcecode, you can use a trick like this without any problem.

  • Am I missing something?  I just applied the Hotfix.  I have my custom JQuery code for one of my Views in it's own .js file being referenced by the .aspx page.  I try to add a debug point in my .js file that contains my custom JQuery for the View.  When I run it using the VS 2008 built-in web server, it never hits the debug point.  I also try to use Intellisense in that .js file and it doesn't do a thing for me.

    Maybe I just don't know how to do this right or maybe it just doesn't work in a .js file and you have to inline your JQuery code right into the .aspx for debugging or Intellisense to work?

  • @Anonymous: IntelliSense (and Debugging) should work from a JS file the same as an ASPX.  I can take a look at your project (or a reduced sample of it) if you send it to jking-at-microsoft-dot-com to see what's wrong. Thanks!

  • Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

  • Here is the latest in my link-listing series .&#160; Also check out my ASP.NET Tips, Tricks and Tutorials

Page 2 of 4 (51 items) 1234