Skip Ribbon Commands
Skip to main content

:

> Posts > SharePoint & jQuery Starter Scripts
March 11
SharePoint & jQuery Starter Scripts

Super quick blog post for you guys. It struck me today the amount of times I have to go to an old script to copy and paste out my script references because I’m too lazy to type them out.

So, here are two scripts that you can drop into SharePoint as a starting point. The first one will get you ready to use SPServices and the second script is for using jQuery and the JavaScript Client Side Object Model (CSOM).

Both scripts reference jQuery from a CDN, so if you have your scripts stored somewhere else be sure to update that.

SPServices and jQuery

<script  type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>

<script type="text/javascript">
     jQuery(document).ready(function($) {
          alert("Okay! Let's get started!");    
     });
</script>

 

Client Side Object Model (CSOM) and jQuery

<script  type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>

<script type="text/javascript">
     ExecuteOrDelayUntilScriptLoaded(PageLoaded, "sp.js");

     function PageLoaded()
     {
           alert("Okay! Let's get started!");
     }
</script>

 

Okay, so maybe I’m the only one that needs these things lying around. At least I know where to grab them now.

Cheers!

Comments

Re: SharePoint & jQuery Starter Scripts

Mark:

I'vew learned the hard way that it';s better for go protocol-less. So, like this:

<!-- Reference the jQueryUI theme's stylesheet on the Google CDN. Here we're using the "Start" theme -->
<link  type="text/css" rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/start/jquery-ui.css" />
<!-- Reference jQuery on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<!-- Reference jQueryUI on the Google CDN -->
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<!-- Reference SPServices on cdnjs (Cloudflare) -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.2/jquery.SPServices-0.7.2.min.js"></script>


See: http://sympmarc.com/2013/02/07/referencing-jquery-jqueryui-and-spservices-from-cdns-revisited/

M.
 on 3/11/2013 9:19 AM

Interesting...

Thanks for the addition Marc... good idea.

Mark
EMS\markrackleyNo presence information on 3/11/2013 9:26 AM

Fantastic.

Thanks Mark.  I agree. These are great to have at your fingertips instead of recreating all the time.

I use scripts like this with a few autotext programs so 3 letters and RETURN spits out code such as this to get me going.

Glad I'm not the only one either.

Charlie Epes
Buffalo, NY

<style type="text/css">
.ms-vb {
 text-align:center;
}
</style>
 on 3/12/2013 8:01 AM

SharePoint Architect, Developer, Blogger, Speaker, Author, and general pain in the butt.
 
Thoughts, views, and opinions expressed in this blog are solely my own.
 
Remember, the Impossible just takes longer.
​​​​
 

 Blogs you should be reading