[Note: This post is a continuation of "SharePoint Customization - My Best Practices Part - 1" where i have discussed my practices for SharePoint front end customization.]
4. Then use this file link in each webpart page where there is customization. To test the usage of this please find the below example of jQuery alert on button click.
a. In your SharePoint page where you want to use the scripts, add a content editor webpart at the top of the page.
b. Now when the page is in edit mode click on the Edit webpart option that appears when a small arrow is clicked on the far most corner.
c. Now in the "Content link" box add the link to your "initialization file". Under the appearance section, In the title box enter the title as "Script Initializer". In the Layout section check "Hidden" option(unless you want it to be visible) and then click "Ok".
d. Add a Content Editor webpart below the "Script Initializer" webpart. Always place the "Script Initializer" webpart at the top of the page.
e. Click on "Click here to add new content", by clicking on this the options at the top gets changed. Click on the option "HTML" under the "Format Text" section. Then select "Edit HTML Source"
f. This brings up a dialog box where we can write our scripts. Enter the following script and click ok and stop the page editing.
g. That is it now when your click on the "Click me" button you should see a alert box "Hurray it works".
5. This shows how we can eliminate problem of losing our code with the reusable script links.
Following the same steps as above we can re-use the styles in our SharePoint Pages.
Post a Comment