Welcome to MSDN Blogs Sign in | Join | Help

Your Websites, Our Passion!

Your official information source from the Visual Web Developer team.

News

  • These postings are provided "AS IS" with no warranties, and confer no rights. Use of included code samples are subject to the terms specified Terms of Use
JScript IntelliSense: Working with jQuery

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

Posted: Friday, February 08, 2008 9:20 PM by WebDevTools

Comments

Mike said:

"I found annotating the library with a few XML Doc Comments..."

That is actually _not_ a positive selling point! Who's gonna write comments for a javascript framework that they use in order to get some intellisense?

# February 9, 2008 5:56 AM

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# February 9, 2008 9:52 AM

Johan Nordberg said:

How about a fix for prototype.js too?

# February 9, 2008 11:53 AM

ajaxus said:

Great stuff! Love to see IntelliSense improving like this!

# February 9, 2008 1:02 PM

WebDevTools said:

Hi Johan: We're working on prototype.js.  Please stay tuned!  Thanks!

# February 9, 2008 7:12 PM

Kevin Radcliffe said:

@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.

# February 10, 2008 2:53 PM

Alan Avante said:

Geez.  What the heck is 'jscript'?  Would you people get over yourselves please?  It's *JAVASCRIPT*.  That's what we are using on the front-lines.  NOT JSCRIPT, whatever the heck that is.

It's just another example of why we programmers are so frustrated w/Microsoft.  Frankly, if it wasn't for Scott Guthrie and his MVC.NET, many of us would start jumping to a platform w/a better IDE (2005 stinks the big one), and better support (ie, COMPATIBILITY and the realization that the net is NOT a Microsoft world and never will be).  Too much innovation happens outside of your very high fences, folks.

So get with the program, please and start acknowledging INDUSTRY STANDARDS!  

# February 11, 2008 11:12 AM

Bilal Haidar [MVP, MCT] said:

The hotfix mentioned in a previous post of mine among the things that it fixed, was an intellisense problem

# February 11, 2008 12:43 PM

WebDevTools said:

Hi Alan: Believe it or not, I would rather use the common term "JavaScript" also.  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.  This leaves me only "ECMAScript" or "JScript" to use.  While "ECMAScript" is actually the standard, I felt "JScript" would click for more people.  Coincidentally, "JScript" is actually the implementation used in IE and in VS, so there is some technical correctness there also.

I'm sorry to hear that VS2005 isn't working out for you.  We try to do our best, so if there's something specific you also don't like in VS2008, I'd like to know.  Thanks!

# February 11, 2008 2:58 PM

Dave said:

Great job, I am glad to see intellisense support working for JQuery.  Good job!

Javascript, JScript, Script, oh my!

# February 11, 2008 5:08 PM

Jeff said:

Okay, not exactly on topic, but I've always found Visual Studio to be the best IDE I've ever used. Visual Studio is a large part of why I got hooked on  Microsoft technology. It has its quirks but they have never prevented me from accomplishing my job.

As far as I'm concerned, keep up the great work!

# February 11, 2008 5:19 PM

Joe On ASP.NET said:

There seems to be allot of interest with ASP.NET Developers doing DOM manipulation with JQuery there

# February 12, 2008 8:48 AM

Joe Stagner - Frustrated by Design ! said:

There seems to be allot of interest with ASP.NET Developers doing DOM manipulation with JQuery there

# February 12, 2008 8:48 AM

Francois Ward said:

You mentionned working on prototype... is ExtJS also in the pipeline? The company I work for is considering it, but we don't really want to use something that won't play well with javascript intellisense...

# February 12, 2008 11:02 AM

WebDevTools said:

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).

# February 12, 2008 1:42 PM

Lance Fisher said:

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.

# February 12, 2008 1:44 PM

Francois Ward said:

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!

# February 12, 2008 3:57 PM

Mike said:

"@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.

# February 12, 2008 5:27 PM

Mike said:

"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.

# February 12, 2008 5:38 PM

Kevin Radcliffe said:

@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

# February 12, 2008 5:55 PM

WebDevTools said:

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.

# February 12, 2008 6:07 PM

ナオキにASP.NET(仮) said:

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

# February 14, 2008 2:26 AM

kristofz said:

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

# February 14, 2008 5:41 AM

James.ToString() said:

JQuery IntelliSense in Visual Studio 2008

# February 15, 2008 10:00 AM

James Hart said:

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.

# February 15, 2008 10:29 AM

Anonymous said:

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?

# February 15, 2008 3:56 PM

WebDevTools said:

@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!

# February 16, 2008 1:52 AM

ScottGu's Blog said:

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

# February 17, 2008 2:01 PM

BusinessRx Reading List said:

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

# February 17, 2008 2:27 PM

Joycode@Ab110.com said:

【原文地址】 Feb 17th Links: ASP.NET, ASP.NET AJAX, Visual Studio, .NET 【原文发表日期】 Sunday, February 17, 2008

# February 17, 2008 5:10 PM

Scott Guthrie Italian WebLog said:

Colegamenti del 17 Febbraio: ASP.NET, ASP.NET AJAX, Visual Studio, .NET

# February 18, 2008 8:18 AM

Mirrored Blogs said:

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

# February 20, 2008 2:51 AM

Kim Jong Il said:

ALan is talking out of his swanny - find me a better IDE than VS and I use it that simple - Jscript - Javascript Alan you so petty.

# February 23, 2008 9:18 PM

vFragoso said:

First of all, sorry for my bad english..

I don't know, how far goes your experience with jQuery, so I'll try hard to make this self-explained.

In jQuery there are some functions that can get or set a value of a css propertie, or an html attribute of the object in question.

Some good examples are the functions width(), height(), css("property"), attr("attribute")..

If you type $(object).width(), you get the value, and $(object).width( val ), you set, of course.

But the problem is how intellisense handles this, since a function like this can return a string, or the jQuery object itfself, allowing you too continue setting other attributes for this same object, like:

$(object).width(val).height(val).css("attribute", "val")

In case you are GETTING the height of the object, for example, intellisense should stop showing after that.

But, if you are SETTING, it should continue working.

A great idea, I guess, is to allow us to define multiple definitions for the same function, like in C# intellisense, choosing one with those cool little arrows.

Something like:

definition

 summary /

 param /

 return type="jQuery" /

/definition

definition

 summary /

 param /

 return type="string" /

/definition

Anyway, thanks for the work so far.

# February 29, 2008 10:04 AM

zjneter said:

Dear Scott:

How about the edition for chinese?  

When ?

# March 4, 2008 1:00 AM

WebDevTools said:

@vFragoso: I completely understand the problem you are describing.  We haven't invented a syntax to address that problem yet.  But we'll see what we can do next release.  C# has it easy because of it's types and clear definition of overloads.  In JS--strictly speaking--anything can affect the return type, from the number of arguements, to the type of the arguments, to the value of the arguments.  To absurdity, you could vary the return type on Math.random().  We would want to account for the variety of possibilities... although probably not that last one. =)

# March 4, 2008 3:12 AM

Levin said:

Hi,

Waiting for you prototype.js fix.:)

# March 4, 2008 9:03 PM

Programming said:

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

# March 6, 2008 5:04 PM

ScottGu's Blog said:

I'm slowly recovering from keynoting at MIX last week, and have been digging my way out of backlogged

# March 14, 2008 3:06 AM

BusinessRx Reading List said:

I'm slowly recovering from keynoting at MIX last week, and have been digging my way out of backlogged

# March 14, 2008 3:28 AM

Mirrored Blogs said:

I&#39;m slowly recovering from keynoting at MIX last week, and have been digging my way out of backlogged

# March 14, 2008 4:06 AM

Loosely Coupled Human Code Factory said:

I knew it was possible, was wondering if or when it would be available. JQuery Intellisense.

# March 21, 2008 1:49 AM

Tommy Skaue said:

We use prototype.js and have been using it for years now. I love the intellisense for js and it's too bad it doesn't work for prototype.

But is it a flaw in prototype.js or VS? Can the prototype crew fix this themselves?

# April 17, 2008 4:24 AM

WebDevTools said:

@Tommy: It's something we're plan on fixing in VS.  I mentioned it here: http://blogs.msdn.com/webdevtools/archive/2008/03/12/jscript-intellisense-working-with-ext-js.aspx.  Thanks!

# April 17, 2008 1:19 PM

linFen said:

JeffKing,who'soneoftheprogrammanagersintheWebToolDivisionandwhofocusesontheJavaScr...

# May 5, 2008 10:41 AM

星辉 said:

JScriptIntelliSense:WorkingwithjQuery

WehavegoodnewsforjQueryfans.

# May 6, 2008 6:20 AM

Your Websites, Our Passion! said:

Visual Studio 2008 SP1 Beta is now available! You can download it here . In SP1, we have added some new

# May 12, 2008 12:08 PM
New Comments to this post are disabled
Page view tracker