问题
I added the vsdoc jquery reference in my js file:
/// <reference path="../jquery-1.4.1.vsdoc.js" />
This works fine, but once I write inside a no conflict wrapper...
(function ($) {
...here...
})(jQuery);
...IntelliSense does not work.
Why is this, and is there any way to solve this?
回答1:
Try adding the <param /> tag at the beginning of your wrapper function:
/// <reference path="../jquery-1.4.1.vsdoc.js" />
(function($) { /// <param name="$" type="jQuery" />
...
})(jQuery);
回答2:
For Visual Studio 2008 when I write
/// <reference path="../jquery-1.4.1.vsdoc.js" />
<intellisense works here>
(function ($) { /// <param name="$" type="jQuery" />
<intellisense doesn't work here>
})(jQuery);
Does uhleeka's answer work in VS2010 and not in 2008? Was there an update to 2010 that changes the params taken?
Edit: I should clarify, it kind of works inside the no wrapper but not completely. Outside of the wrapper I can intellisense $.getJSON, inside I can't. Outside after I close my selector (e.g., $('#test'). a list pops up starting with _load, inside the wrapper after I close the selector no list comes up. Just a few examples of the different behavior.
Does anyone have advice for consistent functionality in regards to no conflict wrappers?
回答3:
/// <reference path="../jquery-1.4.1.js" />
回答4:
If you work with jQuery() instead of $() intellisense works with no problems.
jQuery("#con").click ....
var element = jQuery(this)....
回答5:
Ensure that your jquery intellisense reference files are the first items in your script file.
If you have a comment before your reference line it will not work as in
File: blah **
Do this File: " blah
回答6:
use /// <param name="$" type="jQuery" />
within the closure as its first line.
it worked for me in Visual Studio 2010 SP1.
来源:https://stackoverflow.com/questions/3625363/how-to-get-jquery-visual-studio-2010-intellisense-to-work-inside-a-noconflict-wr