开发者

How to gain IntelliSense support via CDN, when JavaScript and VSDOC files are not local?

When I'm using the Google CDN to acquire the jQuery library, how do I then reference the companion Microsoft CDN VSDOC file to get IntelliSense support in VS 2010?

So far in documentation I've run across instructions to put the VSDOC file alongside the script file in the same folder (in the website) and abide by the naming convention.

e.g.

 /scripts/jquery-1.6.2-vsdoc.js  
 /scripts/jquery-1.6.2.js  

However my files aren't on disk. Can I gain IntelliSense over the netwo开发者_高级运维rk without downloading these files?

jQuery VS Doc location at Microsoft CDN:

http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2-vsdoc.js

JQuery from Google CDN (with Google API key not shown):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" 
    type="text/javascript">
</script>


Yes, as long as the CDN has the -VSDOC file in the same location. Microsoft's CDN does, so just reference the js file from the CDN like this:

<!-- language-all: lang-html -->
<html>
  <head>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
    ...
  </head>
  <body>...</body>
</html>

Note: VS 2008 SP1 does not support this, so don't tear your hair out trying to get it to work!

Source: http://www.asp.net/ajaxlibrary/jquery_intellisense.ashx jump down to the section "Visual Studio 2010, IntelliSense and the CDN".


If you want vsdoc.js for jquery 1.6.2 then u can get it localy using Nuget Package Manger in VS2010.

Go to VSTS2010 --> Tools -> Library Package Manager -> Package Manager Console

And in side Package manager window type this command

PM > Install-Package JQStart

This will install JQStart 1.0.4 Package in your project directory and you can go inside JQStart 1.0.4 Folder and copy jquery-1.6.2-vsdoc.js from its script folder and use it inside your project's Script folder.

Let me know if you have any confusion for above procedure.


In VS2013 The only way I could make this work is copy the VSDOC locally but still use the CDN for the actual script tag. Simply drag the vsdoc.js file (e.g. jquery-2.1.0-vsdoc.js) to your project and its intellisense will be immediately added. VS will even set its build action to None so basically it will have no effect other than residing in your local file system and providing intellisense (it won't be deployed anywhere).

If the library of your choice doesn't have a VSDOC file you could still achieve partial intellisense by dragging the file itself to the project (e.g. knockout-3.1.0.debug.js). If you do, make sure to set the build action to None manually (as VS will assume you actually want to use the file).

So basically drag whatever file you want for intellisense locally, byt reference the CDN in your actual HTML code - at least that's how things work for me on VS2013 Update2 (web essentials installed).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜