SharePoint “Script Editor webPart

1  .Create a webpart page 
2  .Click on Webpart zone “Add a WebPart” and then in Ribbon select “Script Editor”.
3  .Once the webPart is added click the “Edit Snippet” and add JavaScript in it. For this example I added JavaScript that would display current date.
4  .This is a special webpart added to insert HTML\JavaScript\Jquery. You can still add scripts in content query webpart as you did earlier.
Using “Js Link” to add Javascript to Listview\Dataview webpart

In SharePoint 2013 MS has Introduced a new option that could help end-users and admins to add a JavaScript function to a Listview\Dataview webpart without modifying the webpart in SharePoint designer.This new option is “Js Link”.
So In addition to “Xsl Link” (Used to apply an external XSL to the listview webpart) that was available in Webpart properties in previous versions of SharePoint, you now have another option called “Js Link” where you can refer External JavaScript file to be used for the listview webpart. Just to be clear by external I mean a separate file not within the listview webpart. This can be uploaded to your Site asserts library or anywhere in your SharePoint site.
Now let’s see how to refer a Javascript file to a Listview webpart
1. Edit the page where you added your listview webpart (any documents or list webpart).We will use the Out-of-box Document libraray “Documents” for this example.
2. Edit the Documents webpart’s properties select “Edit Web Part” 
  Next in Webpart properties on right expand the last section “Miscellaneous” and scroll down. You would find “Js Link” as last option in Miscellaneous section.

No comments:

Powered by Blogger.