views:

273

answers:

4

I have 2 references to jQuery in my master page which is currently configured for production release:

<script type="text/javascript"
 src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"&gt;
</script>
<%--<script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>--%>

When I'm developing, I uncomment the vsdoc version so that I get intellisense in VS2008 and then switch it back before deploying it - except for the times that I forget. Is there a way to have intellisense in dev and use the Google CDN in prod that doesn't require an edit to deploy? i.e. a conditional inclusion dependent on environment...

EDIT: If I specify this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js as my JavaScript file then VS2008 (with patch) will look for this file: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min-vsdoc.js (with -vsdoc just before the .js) to use for intellisense. The problem is that Google does not provide the second named file in that location.

Another acceptable answer would be the answer to this question: "How do I get Google to put a jquery.min-vsdoc.js file at http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/ ?"

+1  A: 

Visual Studio should automatically look for the vsdoc one for the intellisense.

If your script that is on the page is named "jquery.min.js" then visual studio will look for "jquery.min-vsdoc.js" in the same location.

you'll need to have this hotfix though:

http://blogs.msdn.com/webdevtools/archive/2008/11/07/hotfix-to-enable-vsdoc-js-intellisense-doc-files-is-now-available.aspx

John Boker
Thanks John - but this would rely on Google putting the vsdoc here: http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min-vsdoc.js which they haven't done.
Guy
And thanks for the tip about the patch to get the intellisense although I already had that working when I switched which section of code is commented.
Guy
A: 

Here is a blog post by Scoot Gu on the JQuery intellisense.
Just wanted to point to this blog because it is more exhaustive and worth a read.

Apart from that I think John Boker has answered the question.

Biswanath
+3  A: 

The suggested workaround (since Google doesn't host the documentation) is to reference the documentation script in a way that will never be included, for example

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

OR

<asp:PlaceHolder runat="server" Visible="False">
    <script type="text/javascript" src="../Scripts/jquery-vsdoc.js"></script>
</asp:PlaceHolder>
bdukes
A: 

If you're looking for a VS2008-compatible solution, I use the following:

<%= "<script type='text/jscript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'&gt;&lt;/script&gt;" %>
<% /* %><script type="text/javascript" src="../../App_Data/jquery-1.3.2.js"></script><% */ %>

Blogged about it here: jQuery hosted on Google's CDN with IntelliSense

Stephen Cleary