views:

2367

answers:

4

I am trying to get intellisense in VS2008 in a js file, foo.js, from anther js library/file I've written but cannot figure out the reference path ?syntax?/?string?

The library is in a file called common.js which is in the same folder as foo.js I'm working on.

Here's the paths I've tried...

/// <reference path="../../scripts/common.js"/>
/// <reference path="/../scripts/common.js"/>
/// <reference path="../scripts/common.js"/>
/// <reference path="/scripts/common.js"/>
/// <reference path="scripts/common.js"/>
/// <reference path="/common.js"/>
/// <reference path="../common.js"/>
/// <reference path="/common.js"/>
/// <reference path="common.js"/>

What's the secret path syntax/string that I'm missing?

FWIW the top path is what is set in the master page of this MVC app...like so

<script type="text/javascript" src="../../scripts/common.js"></script>

Thanks Greg

A: 

There seem to be a few voices out there saying something is broken in this regard. Workaround for Beta 2 JavaScript IntelliSense and Colorization Issue for instance.

One suggestion, which would seem to be something you've already tried is VS 2008 JavaScript Intellisense for Silverlight From ScottGu, but you could also check out the JavaScript Intellisense Support in Visual Studio 2008 video.

HTH.

boost
A: 

Did you try the VS hotfix for jQuery intellisense? http://blogs.msdn.com/webdevtools/archive/2008/02/08/jscript-intellisense-working-with-jquery.aspx

StingyJack
That hotfix is from Feb/Mar 08 timeframe...I did install this hotfix for jQeury tho http://www.west-wind.com/Weblog/posts/536756.aspx or here http://code.msdn.microsoft.com/KB958502
w4ik
yeah that one. I have an old bookmark, sorry.
StingyJack
+1  A: 

First, make sure "common.js" is in your web project. Then drag "common.js" from the solution explorer into the editor window for the file you want to reference it from.

Alan Oursland
Alan...that added added this line /// <reference path="common.js" />which is awesome... but still no intellisense :(
w4ik
Do you get errors when you press Ctrl-Shift-J in foo.js?Do you see the status bar displaying "Genearting Intellisense..." when you press Ctrl-Shift-J?
Alan Oursland
I do see the status bar displaying "Generating Intellisense..." Here's something I've just discovered...I do have intellisense when I embed some JS in the view(aspx page) but not in the JS file foo.js...weird...
w4ik
+2  A: 

Finally...finally got jQuery intellisense to work...
From here http://blogs.msdn.com/webdevtools/archive/2007/11/06/jscript-intellisense-a-reference-for-the-reference-tag.aspx

the author says

Here are a few other subtle tips:

  • Remember, reference statements must precede all other content in the file-even normal comments.

And that was what fixed the issue for me...placed the reference statements at the very top and... voila!... intellisense works!

So just for grins here's what the first lines of my file look like

/// <reference path="common.js" />
/// <reference path="jquery-1.2.6.js" />
/// <reference path="jquery.formatCurrency.js" />
/*
 * Foo Scripts/foo Script: foo.js
 * Version 1.0
 * Copyright(c) 2008 FUBAR Management, LLC. All Rights Reserved.    
 */

Originally I had the reference statements below the Foo Scripts comments arghhhh!

w4ik