Monday, July 15, 2013

Using jQuery with Sharepoint 2010

 

1. Download jQuery

Download latest verion of jQuery here http://docs.jquery.com/Downloading_jQuery

2. Save it in an Accessible Location in Sharepoint

Using Sharepoint Designer I added a Folder called “Scripts” inside the “Style Library” of the root level of the site. I then added the latest jQuery File into that folder.

3. Place a reference on that jQuery from your code

The best place for this will be your master page so that it can be used anywhere in your site, so open the master page (by default SharePoint 2010 uses v4.master) you are using in Advanced mode then add your javascript reference like such.

Collapse | Copy Code

<script src="/Style%20Library/Scripts/jquery-1.6.2.js" type="text/javascript"></script>

you place that inside the <head> tag


Save that master page and you are ready to go

4. Test if its working

If you are using FireFox open up firebug or if you are using IE you can press F12. Go to the script tab to check whether your javascript reference is there, then on the console window try wether that reference works by typing something like this.

Collapse | Copy Code

$("#MSO_ContentTable").text("Welcome to Sharepoint jQuery")

you should get a result something like this

No comments:

Post a Comment