SharePoint JS Link (5) FAQs about JSLink, sharepointjslink

Source: Internet
Author: User
Tags xslt

SharePoint JS Link (5) FAQs about JSLink, sharepointjslink

FAQs about JSLink


1. Where can JSLink be applied?

JSLink can be applied to fields, Web Parts, list forms, views, and content types ).


2. Where can the JSLink file be stored?

JSLink can be placed in any document library in SharePoint or in the layout folder. In different locations, the prefixes are different during reference:

§~ Site-indicates that the JSLink file to be referenced is under the current site

§~ Sitecollection-indicates that the JSLink file to be referenced is located under the website set of the current site

§~ Layouts-indicates that the JSLink to be referenced is under _ layouts/15

§~ Sitecollectionlayouts-indicates that the JSlink to be referenced is in the layouts folder of the current website set (for example,/sites/mysite/_ layouts/15 ).

§~ Sitelayouts-indicates that the JSlink to be referenced is in the layouts folder of the current site (for example, site/mysite/mysubsite/_ layouts/15 ).

 

3. Where can JSLink be changed?

The template object used to register the modification method has the following attributes: Header, Body, Footer, OnPreRender, OnPostRender, Group, Item and Fields. You can rewrite the display style in these places.


4. How should I modify all the forms in a list?

If you want to modify the style of a filed in different forms, you can follow the example below to write them: View, DisplayForm, EditForm, and NewForm.

siteCtx.Templates.Fields= {  //MyCustomField is the Name of our field 'MyCustomField': { 'View': customView, 'DisplayForm': customDisplayForm, 'EditForm': customNew, 'NewForm': customEdit  }};


5. JSLink vs. XSL/XSLT

JSLink has some advantages over XSL/XSLT. First, it uses JavaScript, which is familiar to most Web developers. XSLT is difficult in development and debugging. Therefore, JSLink can reduce development time and costs.

Using JavaScript, HTML, and CSS for rendering on the client avoids unnecessary loads on the server, improves the overall loading speed, and enables better page response.

Then, you can use JSLink to customize all the parts of a view. For example, if you only want to customize a field, you only need to rewrite this part of the logic. The other part is still based on the previous logic. Using JSLink, you can also use JaveScript, including some popular plug-ins, such as jQuery.

Of course, there are deficiencies in any technology, as is JSLink. For example, if your browser blocks JaveScript, JSLink will not work. Server-side Rendering using XSLT won't solve this problem, but it will be efficient.

If a user's browser or system is very old, executing the Script will also speed down the show.

In the end, when a search engine crawls the internet, it prefers static html code instead of dynamic content generated by Ajax/JavaScript. Therefore, if your website is public-oriented, JSLink is not the best choice.

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.