How to get jQuery Visual Studio 2010 IntelliSense to work inside a noconflict wrapper

别来无恙 提交于 2019-12-04 13:25:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!