Welcome to EMC Consulting Blogs Sign in | Join | Help

Matt Hall's Blog

Experiences with Microsoft technologies

Visual Studio 2008 JQuery Intellisense

After following through various step-by-step instructions on getting the JQuery intellisense to work with Visual Studio 2008 SP1, I was still having issues getting it to work correctly.  The first and slightly more obvious reason for the intellisense to not work was down to using absolute paths for the script file.

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

This should be

<script type="text/javascript" src="~/Scripts/jquery-1.3.2.min.js"></script>

The second and far more idiosyncratic problem was occurring when I had also referenced other script files. So, I would have something like the following.

<script type="text/javascript" src="~/Scripts/jquery-1.3.2.min.js"></script>

<script type="text/javascript" src="~/Scripts/another-script.js"></script>

 

Strangely enough every time I referenced an additional script to the jquery core in my Site.Master the intellisense would suddenly stop working. It turns out that there is a dependency on an associated file named with a –vsdoc suffix to the script filename.

For the above example you would need an “another-script-vsdoc.js” file located in the same folder as the actual script file. It doesn’t matter whether this contains any comments to support Visual Studio intellisense, it merely needs to exist.

An additional note to point out is that the intellisense will not work if you are using any kind of server side scripting in the path, which is also pretty obvious if you think about it.

<script type="text/javascript" src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.min.js")%>"></script>

Published 08 April 2009 14:59 by Matthew.Hall

Comments

 

Will said:

thank you Mark! did the job nicely

April 17, 2009 06:52
 

Will said:

I should also mention that using the ~ on non-server controls does not resolve, hence I've had to add/remove the ~ depending on whether I'm coding or publishing. Do you know of a workaround?

April 17, 2009 07:46
 

Biruk said:

awesome Dude! you have no idea how much you helped me.

April 20, 2009 20:39
 

Matthew.Hall said:

@Will

I have been doing a little hack like so for the time-being

<%
if (false)
{
%>       
   <script type="text/javascript" src="~/Scripts/jquery-1.3.2.min.js"></script>
<%} %>       

<script type="text/javascript" src="<%=ResolveUrl("~/Scripts/jquery-1.3.2.min.js")%>"></script>
April 21, 2009 16:39
 

Will said:

ah excellent, works a treat. thank you again

April 23, 2009 03:03
 

lufutu said:

Thanks you very much, very useful !

May 4, 2009 16:39
New Comments to this post are disabled
Powered by Community Server (Personal Edition), by Telligent Systems