I added the vsdoc jquery reference in my js fi开发者_如何学Pythonle:
/// <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?
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);
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?
/// <reference path="../jquery-1.4.1.js" />
If you work with jQuery() instead of $() intellisense works with no problems.
jQuery("#con").click ....
var element = jQuery(this)....
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
use /// <param name="$" type="jQuery" />
within the closure as its first line.
it worked for me in Visual Studio 2010 SP1.
精彩评论