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

你离开我真会死。 提交于 2019-12-03 09:31:54

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.

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