ArticleDirectory
Http://www.cnblogs.com/tonybinlj/archive/2009/05/26/1490434.html
Enable Visual Studio's smart awareness of jquery
First, let's take a look at the smart perception surprises that Visual Studio brings to us. To enable Visual Studio to Support SMART awareness, we need the following conditions:
When writing a script or even entering "$", VS can intelligently prompt:
When using this method, there will be more tips:
With Intelligent Sensing, writing JavaScript becomes as fast, convenient, and comfortable as C. in most cases, you can write a file successfully at a time without querying the Javascript help file for Case sensitivity. the premise that Visual Studio can intelligently perceive jquery is to introduce the jquery class library of vsdoc version. in the example, we introduced the "jquery-1.3.2-vsdoc2.js" file. if you reference A jquery class library of another version, such as Min, you cannot enable the smart notification function. however, in the official environment, we must use the jquery library file of the "min" version. Take Version 1.3.2 as an example. The size of each version is as follows:
The first one is the uncompressed jquery library. If you enable gzip compression and use the min version of jquery. JS, You can scale the file to 19kb during transmission.
Note: If the script is updated, you can use the "Ctrl + Shift + J" shortcut to update Visual Studio's smart awareness, or click Edit-> intelliisense-> Update JScript intelliisense:
To add a script prompt in Visual Studio and use the script library of the min version when going online, we generally use the following method to introduce the jquery Library:
1. control compilation results
<SCRIPT type = "text/JavaScript" src = "scripts/jquery-1.2.6.min.js"> </SCRIPT>
<% IF (false)
{%>
<SCRIPT type = "text/JavaScript" src = "scripts/jquery-1.3.2-vsdoc2.js"> </SCRIPT>
<% }%>
This is a recommended method on the Internet. After compilation, only the reference of the min version is available on the page, and smart sensing is available during development. However, pay attention to this method.The referenced min class library can only be 1.2.6 or earlier versions. After referencing all the jquery libraries of the latest 1.3.2 Non-vsdoc version, the JScript intelliisense update error will occur.This is a bug in Version 1.3.2 and is expected to be solved in later versions. In fact, you can use the min library of version 1.2.6. jquery functions involved in this tutorial are basically supported in version 1.2.6.
If (false) is used to make the compiled page not contain references of the jquery library of vsdoc version, the same idea can also be used, for example, to put the script reference into a placeholder and set visible = fasle.
2. Use backend Variables
In order to use the min library of Version 1.3.2, we can only place the Script Reference in the variable and use the page output method to normally update JScript intelliisense. however, some people may not like to use variables at the front end like me:
<Asp: placeholder visible = "false" runat = "server">
<SCRIPT type = "text/JavaScript" src = "scripts/jquery-1.3.2-vsdoc2.js"> </SCRIPT>
</ASP: placeholder>
<% = Jqueryscriptblock %>
Background declaration variables:
Protected string jqueryscriptblock = @ "<SCRIPT type =" "text/JavaScript" "src =" "scripts/jquery-1.3.2.min.js"> </SCRIPT> ";
Enable script intelligent sensing in an independent. JS File
The above solves the problem of intelligent perception on the page. In fact, we can also enable script intelligent awareness in an independent. js file. In the intelliisensedemo. js file, add the following statement:
// <Reference Path = "jquery-1.3.2-vsdoc2.js"/>
When you update JScript intelliisense, you will find that smart prompts are also enabled in the script:
Note: The Script smart sensing described in this article is not only applicable to jquery class libraries, but also to self-compiled JavaScript code.
Related Questions
Warning 1 error updating JScript intelliisense: D: \ jqueryt \ JS \ jquery-1.3.2.js: object does not support this attribute or method @ 2139: 1 D: \ jqueryt \ htmlpage.htm 1 1 D: \ jqueryt \
I checked and found that the problem is jquery-1.3.2-vsdoc2.js, I downloaded from the official file, the name has not changed this. But there is a problem.
To: jquery-1.3.2-vsdoc.js, Update the smart prompt again, OK. The error disappears.