SharePoint learning notes-ecmascript object model series-2. intelligently prompts when writing code

Source: Internet
Author: User

Use the ecmascript object model to compileCodePreviously, we certainly wanted our coding process to be as easy as possible, so here let's look at how to implement the smart prompt function when writing code.
1. Create a Javascript file in vs2010.

2. Add the following code at the beginning of the file:

/// < Reference Name = "Microsoftajax. js" />

We must. javascript references are placed on the first line. Javascript has a certain degree of attention to the order of external reference files. Some SP objects will depend on Microsoft tajax. JS. If we place this file in a random place, it will cause some errors that reference the SP object.

You can also introduce debug files, that is, "microsoftajax. debug. JS ", because this file makes the prompt displayed by Visual Web Developer's intelliisense more intuitive, for example, the prompt for $ get is $ get (string ID, element ), if we introduce a file without debug, the prompt is $ get (F, E), because the file without debug is compressed.

 

3. Next, we need to add two other JS files to support our smart prompts: sp. Core. Debug. js and sp. Debug. js.

Reference:

/// < Reference Path = "File: // C:/program files/common files/Microsoft shared/Web Server Extensions/14/template/layouts/sp. Core. Debug. js"   />
/// < Reference Path = "File: // C:/program files/common files/Microsoft shared/Web Server Extensions/14/template/layouts/sp. Debug. js"   />

The sp. Core. Debug. js and sp. Debug. js files are the main files used to debug and develop the ecmascript code.
4. Similarly, we can continue to add any other js code file references, such as: sp. ribbon. debug. JS, SP. UI. admin. debug. JS to support the development and debugging of such object models. For example, if we need to use the ecmascript object to operate the ribbon object, we need to add SP. ribbon. Debug. js. This is used as follows:

/// < Reference Path = "File: // C:/program files/common files/Microsoft shared/Web Server Extensions/14/template/layouts/sp. ribbon. Debug. js"   />

It is worth noting that these JS files are generally located in the C:/program files/common files/Microsoft shared/Web Server Extensions/14/template/layouts directory.
5. Write our JS Code and check the effect as follows:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.