Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery intellisense vs2010 mvc3

jQuery intellisense does not work for me unless I place:

<script src="../../Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>

...in the page. I thought putting it in the _Layout.cshtml would be sufficient but it's not.

I have to do this on every page, partial etc.

Is this a bug or is there a better way to enable jQuery intellisense across all the pages and .js files?

like image 548
raklos Avatar asked Dec 23 '10 23:12

raklos


3 Answers

You can also use an if clause like:

 @if (false) { 
    <script src="/Scripts/jquery-1.4.4-vsdoc.js" type="text/javascript"></script>
 }
like image 80
kapsiR Avatar answered Nov 15 '22 23:11

kapsiR


If u need to add jQuery intellisense to a .js file, add this:

 /// <reference path="../../Scripts/jquery-1.5.1.min.js" />

If u need to add to a .cshtml file, try this:

 @* <reference path="../../Scripts/jquery-1.5.1.min.js" />*@

Visual Studio can read these refs even if they are in comments...which is kinda interesting.

like image 30
brad oyler Avatar answered Nov 15 '22 23:11

brad oyler


Currenty you need to add a reference to a script in the file that you are editing for JavaScript IntelliSense to work in that fie. This is because layouts in Razor are set imperatively during the page's execution and not declaratively.

Note that you should be able to put HTML comment blocks around your script references so that multiple references to the same script file will be ignored when rendered in the browser.

like image 34
marcind Avatar answered Nov 16 '22 00:11

marcind