Domanda

As I understand it, you should be able to (with KB958502 installed) get Intellisense for jQuery simply by referencing the script (as long as the -vsdoc version is alongside).

We'd quite like to use a CDN for distributing this, but simply adding:

<script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.js"></script>

Gives an obscure warning

Warning 1 Error updating JScript IntelliSense: C:...\Temporary Internet Files\Content.IE5\4U5FWPZF\jquery-1.7.1-fds901..js: Object doesn't support this property or method @ 1352:1 c:\Projects...\MyFile.aspx

At a guess, I'd assume that it's "having a sulk" because the file name in the cache isn't of the form jquery-1.7.1-vsdoc.js, especially as the error remains the same, even if I go the whole way with:

<script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.js"></script>
<script language="javascript" type="text/javascript">
 // This is for jQuery intelisense:
 /// <reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1-vsdoc.js"/>

 $(function() {
  // My other code...
 });

</script>

This still doesn't work.

Is it simply the case that vsdoc Intellisense does not work with remotely hosted files?

È stato utile?

Soluzione

I don't think that it's possible, at least without any 3rd party tools or complex hacks ( I don't know of any ). What I've always done in the past is download jquery and from your js files you can add

 /// <reference path="Scripts/jquery.js"/>

for intellisense, but in your pages, get the library from the CDN. Just because the script is referenced in your js does not make the browser download this, so you will only be getting the script from the cdn when running.

Altri suggerimenti

You really should have a local backup copy of jQuery anyways, otherwise if there is some problem with CDN, people can reach your page but it fails because it can't load from teh CDN.

If you have a local copy, then it will work. The CDN is simply to avoid users having to download a new copy when they first come to your site, if they've been to a different site that also uses the same CDN.

This is working for me. I'm fully patched up on Win7 x64. It takes several seconds for VS to download and parse the script file after the first time I type $, but it works and it works well.

Edit: Now I seem to get the error, but sporadically. Have you tried refreshing your Intellisense cache with Shift+Ctrl+J?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top