SlideShare a Scribd company logo
1 of 40
THE SHAREPOINT AND
JQUERY GUIDE
SharePoint Saturday Twin Cities
May 18th, 2013
Mark Rackley
mark.rackley@summit7systems.com
» Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with
companies such as Microsoft, Oracle and IBM.
» Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and
models to the solution provider industry.
» Top 1% of Microsoft Partners Worldwide
» Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year.
» ~ 50% of Technical Staff hold US Government SECRET Clearances.
» Service Disabled Veteran Owned Small Business (SDVOSB).
Summit 7 systems is a premier provider of consulting and implementation services specializing on the
Microsoft SharePoint Platform and FAST Enterprise Search.
» Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with
companies such as Microsoft, Oracle and IBM.
» Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and
models to the solution provider industry.
» Top 1% of Microsoft Partners Worldwide
» Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year.
» ~ 50% of Technical Staff hold US Government SECRET Clearances.
» Service Disabled Veteran Owned Small Business (SDVOSB).
SERVICES
SharePoint QuickStart
Information Architecture and Governance Development
Upgrade and Migration
Branding and Design (User Experience)
Web Content Management Design and Deployment
SharePoint Search
Custom Workflow or Web Part Development
InfoPath Forms and Workflows
Performance Baselines and Best Practices Optimization
Mapping Business Process to Software Platforms
Cloud Services Design and Provisioning
Remote Support Contracts
Compliance Quickstart
SOFTWARE PLATFORMS
FAST Enterprise Search
SharePoint 2007
SharePoint 2010
SharePoint 2013
Office Platform
Sitecore
SOLUTION AREAS
SharePoint Platform Solutions
Enterprise Search
Enterprise Content Management
Internet / Web Content Management
Extranet Solutions
Intranet Solutions
Business Process Management
Enterprise Project Management
Exchange Server
SERVICES
SharePoint QuickStart
Information Architecture and Governance Development
Upgrade and Migration
Branding and Design (User Experience)
Web Content Management Design and Deployment
SharePoint Search
Custom Workflow or Web Part Development
InfoPath Forms and Workflows
Performance Baselines and Best Practices Optimization
Mapping Business Process to Software Platforms
Cloud Services Design and Provisioning
Remote Support Contracts
Compliance Quickstart
SOFTWARE PLATFORMS
FAST Enterprise Search
SharePoint 2007
SharePoint 2010
SharePoint 2013
Office Platform
Sitecore
SOLUTION AREAS
SharePoint Platform Solutions
Enterprise Search
Enterprise Content Management
Internet / Web Content Management
Extranet Solutions
Intranet Solutions
Business Process Management
Enterprise Project Management
Exchange Server
• 18+ years software architecture and
development experience
• SharePoint Junkie since 2007
• Event Organizer
• Blogger, Writer, Speaker
• Bacon aficionado
MARK RACKLEY / SOLUTIONS ARCHITECT
@mrackley http://www.sharepointhillbilly.com
AGENDA
• What is jQuery? Why SharePoint & jQuery?
• SharePoint and jQuery Basics
• Deploying / Maintaining
• Development Basics
• Third Party Libraries
• Examples & Demos
The SharePoint & jQuery Guide
http://bit.ly/jQueryAndSP
WHAT IS JQUERY?
• JavaScript Utility Library
• jQuery() or $()
• Allows interaction and manipulation of the DOM after
page is rendered
• Can interact with other systems using Web Services
• Supported by Microsoft
• Part of “Client Side” Development
WHY SHAREPOINT & JQUERY?
• Fewer upgrade/deployment issues
• Rapid deployment and modifications
• Less “customization”
• Improved visuals
• Improved usability
WHY SHAREPOINT & JQUERY?
• Can replace the need for Visual Studio
• Can replace the need for basic workflows
• No points (shhhh… don’t tell the admins)
• Can get around list view threshold
JQUERY & SHAREPOINT BASICS
• Scripts execute with same privileges as current user
• Permissions cannot be elevated
• Interact with SharePoint List data using Client Side Object
Model (CSOM) or SPServices
• View the DOM not the Page Source
WHY I HATE JAVASCRIPT & JQUERY (SOME DAYS)
• Too many optionsvar car = {
color: “red”,
make: “Jeep”,
model: “wrangler”
}
var car = {};
car.color = “red”;
car.make = “Jeep”;
car.model=“wranger”;
var car = {};
car*“color”+ = “red”;
car*“make”+ = “Jeep”;
car*“model”+ =“wranger”;
WHY I HATE JAVASCRIPT & JQUERY (SOME DAYS)
• Too many options
• Debugging is painful
• Performance can suffer
• Inconsistent results on different browsers
• Constant changes in the jQuery library
• It CAN harm your farm!
WHEN SHOULD YOU USE JQUERY?
• Tightly controlled environments
• Visuals or Usability are high priorities
• Tight timeframes
• Simple page and form modifications
› Dynamic drop downs
› Hiding page elements
› Reading / populating fields
• Why would you NOT use jQuery?
WHEN SHOULD YOU QUESTION THE USE OF JQUERY?
• Need pull a lot of data over the wire to work with
• Iterating over many rows of list data
• Extended business logic or proprietary business logic
• Privileges need to be elevated
• Need to support many different browsers
DEPLOYMENT AND REFERENCE OPTIONS
• Deployment Options
• Document Library
• File System
• Content Delivery Network (CDN)
• Reference Options
• ScriptLink
• Content Editor Web Part
• Custom Action (deploys to Site Collection)
DOCUMENT LIBRARY
CUSTOM ACTION
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
ScriptSrc="~sitecollection/SiteAssets/jquery.min.js"
Location="ScriptLink"
Sequence="100"
>
</CustomAction>
</Elements>
DEVELOPMENT & DEBUGGING
• Development
• Visual Studio
• Web Essentials
• TypeScript
• SharePoint Designer
• Notepad++
• Debugging
• IE Developer Tools / Firebug
• Fiddler
• Alerts… alerts… alerts…
• Avoid Console.log
• Write scripts in small manageable chunks
HOW ABOUT SOME BEST PRACTICES?
• Use the Element’s ID when possible
• Reduce DOM searches
• Re-use code / Good coding practices
• Minimize files
• Use animations to hide slow performance
• Delay loading of Selects until you need the data
USING THIRD PARTY LIBRARIES
Tips for selection and integration
• Look for supported / documented libraries
• Test in target browsers before implementing
• Duplicate file structure
• Test “vanilla” in SharePoint first
USING THIRD PARTY LIBRARIES
Some of my favorites
• Content Slider - http://www.awkwardgroup.com/sandbox/awkward-showcase-a-jquery-
plugin/
• Formatted Tables - http://www.datatables.net/
• Modal Window - http://www.ericmmartin.com/projects/simplemodal/
• SPServices - http://spservices.codeplex.com/
• Calendar - http://arshaw.com/fullcalendar/
• InfoPath Forms Alternative – http://forms7.codeplex.com
BASICS / INTERACTING WITH
FORMS
BASICS
Method Description
$(document).ready(function($){}) Where code execution begins after page is loaded
$(“#ElementID”) Returns element with given id
$(“element.class”) Returns all elements of a particular class
$(“div.myClass”)
$(“Type*attrib=‘value’+”) Gets element of specific type and attribute value $(“input*Title=‘First
Name’+”)
.show(), .hide(), .toggle() Shows, hides, toggles
.html() Gets the raw html for an element with tags
.text() Contents of an element with HTML tags stripped out
INTERACTING WITH SHAREPOINT FORMS
Getting/Setting SharePoint Form Fields
Text Boxes
› $(“input*title=’My Text Field’+”).val();
Selects
› $(“select*title=’My Choice’+”).val(mySelectValue);
Checkboxes
› $("input[title='My Check box']").removeAttr('checked');
› $("input[title='My Check box']").attr('checked','checked');
<input
name="ctl00$m$g_a12c0b73_06fa_4552_a5af_b5d5fce55384$ctl00$ctl05$ctl03$ctl00$ctl00
$ctl04$ctl00$ctl00$TextField" type="text" maxlength="255"
id="ctl00_m_g_a12c0b73_06fa_4552_a5af_b5d5fce55384_ctl00_ctl05_ctl03_ctl00_ctl00_ctl
04_ctl00_ctl00_TextField" title="E-mail Address" class=“ms-long ms-spellcheck-true" />
$(“input[title=‘E-mail Address’+”); //returns element
$(“input”).each(function(),
$(this).attr(“title”); // gets the value of the title attribute for all inputs
});
DEMO 1: BASICS / INTERACTING
WITH FORMS
READ LIST ITEMS WITH
SPSERVICES
<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($) {
LoadSpeakers();
});
</script>
<table id='speakerTable'><tr><th>Picture</th><th>Name</th><th>Blog</th></tr></table>
<script type="text/javascript">
function LoadSpeakers(){
var listTitle = "Speakers";
var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'>0</Value></Neq></Where></Query>";
var camlViewFields = "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Blog' /><FieldRef Name='Picture' /></ViewFields>";
$().SPServices({
operation: "GetListItems",
async: true,
listName: listTitle,
CAMLViewFields: camlViewFields,
CAMLQuery: query,
completefunc: function(xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var speakerName = ($(this).attr("ows_Title"));
var picture = $(this).attr("ows_Picture").split(",")[0];
var blog = $(this).attr("ows_Blog").split(",")[0];
$("#speakerTable").append("<tr><td><img width='50' src='"+ picture +"'></td><td>"+speakerName +"</td><td>"+blog +"</td></tr>");
}); // end completefunc
}
}); // end SPS
}
</script>
SPSERVICES READ LIST ITEMS
DEMO 2: READ LIST ITEMS WITH
SPSERVICES
READ LIST ITEMS WITH CLIENT
SIDE OBJECT MODEL
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(LoadSpeakers, "sp.js");
</script>
<table id='speakerTable'><tr><th>Picture</th><th>Name</th><th>Blog</th></tr></table>
<script type="text/javascript">
function LoadSpeakers() {
var listTitle = "Speakers";
context = SP.ClientContext.get_current();
var speakerList = context.get_web().get_lists().getByTitle(listTitle);
var camlQuery = SP.CamlQuery.createAllItemsQuery();
this.listItems = speakerList.getItems(camlQuery);
context.load(listItems);
context.executeQueryAsync(ReadListItemSucceeded, ReadListItemFailed);
}
function ReadListItemSucceeded(sender, args) {
var enumerator = listItems.getEnumerator();
while (enumerator.moveNext()) {
var listItem = enumerator.get_current();
var blog = listItem.get_item('Blog').get_url();
var speakerName = listItem.get_item('Title');
var picture = listItem.get_item('Picture').get_url();
$("#speakerTable").append("<tr><td><img width='50' src='"+ picture +"'></td><td>"+speakerName +"</td><td>"+blog +"</td></tr>");
}
}
function ReadListItemFailed(sender, args) {
alert('Request failed. ' + args.get_message() + 'n' + args.get_stackTrace());
}
</script>
CLIENT SIDE OBJECT MODEL READ LIST ITEMS
DEMO 3: READ LIST ITEMS WITH
CLIENT SIDE OBJECT MODEL
SEARCHING THE DOCUMENT
OBJECT MODEL
SEARCHING DOM
Method Description
.split() lookUpFieldValue = “1;#Mark Rackley”;
Var myArray = numbers.split(“;#”);
myArray*1+ == “Mark Rackley”
.replace() var myString = “This string has spaces”;
var newString = myString.replace(/ /g,””);
newString == “Thisstringhasspaces”;
.contains() Check to see if a DOM element is within another DOM element
.find() Get the child elements of current element, filtered by a selector
Chaining:
$("nobr b:contains('Sum= ')").html().split("= ")[1].replace(",","")
DEMO 4: SEARCHING THE
DOCUMENT OBJECT MODEL
Tabbed Web Parts in SharePoint 2013 / Office 365
http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=42
DEMO 5: BING MAP DEMO
Integrating SharePoint and Bing Maps
http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=19
CREATING CUSTOM FORMS
Forms7 – An InfoPath Forms Alternative
https://forms7.codeplex.com/
MORE DEMOS
Special thanks to our sponsors…
summit7systems
summit7systems.com/blogs
FOR MORE FROM SUMMIT 7 SYSTEMS…
facebook.com/summit7systems
@summit7systems
summit 7 systems

More Related Content

What's hot

SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
Mark Rackley
 
Intro to SharePoint Web Services
Intro to SharePoint Web ServicesIntro to SharePoint Web Services
Intro to SharePoint Web Services
Mark Rackley
 
What is SharePoint Development??
What is SharePoint Development??What is SharePoint Development??
What is SharePoint Development??
Mark Rackley
 

What's hot (20)

The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14The SharePoint & jQuery Guide - Updated 1/14/14
The SharePoint & jQuery Guide - Updated 1/14/14
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
#SPSTC Maximizing the SharePoint User Experience with Free 3rd Party jQuery L...
 
TulsaTechFest - Maximize SharePoint UX with free jQuery libraries
TulsaTechFest - Maximize SharePoint UX with free jQuery librariesTulsaTechFest - Maximize SharePoint UX with free jQuery libraries
TulsaTechFest - Maximize SharePoint UX with free jQuery libraries
 
Intro to SharePoint Web Services
Intro to SharePoint Web ServicesIntro to SharePoint Web Services
Intro to SharePoint Web Services
 
Introduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPathIntroduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPath
 
Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePoint
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
 
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsSPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
 
SEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePointSEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePoint
 
What is SharePoint Development??
What is SharePoint Development??What is SharePoint Development??
What is SharePoint Development??
 
SEF2013 - Create a Business Solution, Step by Step, with No Managed Code
SEF2013 - Create a Business Solution, Step by Step, with No Managed CodeSEF2013 - Create a Business Solution, Step by Step, with No Managed Code
SEF2013 - Create a Business Solution, Step by Step, with No Managed Code
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
SharePoint Performance
SharePoint PerformanceSharePoint Performance
SharePoint Performance
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form Usability
 
A Power User's Intro to jQuery Awesomeness in SharePoint
A Power User's Intro to jQuery Awesomeness in SharePointA Power User's Intro to jQuery Awesomeness in SharePoint
A Power User's Intro to jQuery Awesomeness in SharePoint
 
SharePoint REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOM
 
NOW I Get it!! What SharePoint IS and why I need it
NOW I Get it!! What SharePoint IS and why I need itNOW I Get it!! What SharePoint IS and why I need it
NOW I Get it!! What SharePoint IS and why I need it
 

Similar to SharePoint & jQuery Guide - SPSTC 5/18/2013

Practical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
Practical Business Intelligence in SharePoint 2013 - Helsinki FinalndPractical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
Practical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
Ivan Sanders
 
Feature driven agile oriented web applications
Feature driven agile oriented web applicationsFeature driven agile oriented web applications
Feature driven agile oriented web applications
Ram G Athreya
 
Developing for SharePoint Online
Developing for SharePoint OnlineDeveloping for SharePoint Online
Developing for SharePoint Online
Ari Bakker
 
SharePoint 2013 Dev Features
SharePoint 2013 Dev FeaturesSharePoint 2013 Dev Features
SharePoint 2013 Dev Features
Ricardo Wilkins
 
SharePoint Online vs. On-Premise
SharePoint Online vs. On-PremiseSharePoint Online vs. On-Premise
SharePoint Online vs. On-Premise
Evan Hodges
 

Similar to SharePoint & jQuery Guide - SPSTC 5/18/2013 (20)

The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechConThe SharePoint and jQuery Guide by Mark Rackley - SPTechCon
The SharePoint and jQuery Guide by Mark Rackley - SPTechCon
 
Practical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
Practical Business Intelligence in SharePoint 2013 - Helsinki FinalndPractical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
Practical Business Intelligence in SharePoint 2013 - Helsinki Finalnd
 
Practical Business Intelligence in SharePoint 2013 - Honolulu
Practical Business Intelligence in SharePoint 2013 - HonoluluPractical Business Intelligence in SharePoint 2013 - Honolulu
Practical Business Intelligence in SharePoint 2013 - Honolulu
 
Feature driven agile oriented web applications
Feature driven agile oriented web applicationsFeature driven agile oriented web applications
Feature driven agile oriented web applications
 
Lifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and SolutionsLifecycle Management with SharePoint Apps and Solutions
Lifecycle Management with SharePoint Apps and Solutions
 
SharePoint 2013 Admin in the Hybrid World
SharePoint 2013 Admin in the Hybrid WorldSharePoint 2013 Admin in the Hybrid World
SharePoint 2013 Admin in the Hybrid World
 
When to Develop on a Platform (IndyTechFest 2008)
When to Develop on a Platform (IndyTechFest 2008)When to Develop on a Platform (IndyTechFest 2008)
When to Develop on a Platform (IndyTechFest 2008)
 
Intro to SharePoint for Developers
Intro to SharePoint for DevelopersIntro to SharePoint for Developers
Intro to SharePoint for Developers
 
Practical Business Intelligence with SharePoint 2013
Practical Business Intelligence with SharePoint 2013Practical Business Intelligence with SharePoint 2013
Practical Business Intelligence with SharePoint 2013
 
SPTechCon Austin - The Slippery Slope of SharePoint Migrations
SPTechCon Austin - The Slippery Slope of SharePoint MigrationsSPTechCon Austin - The Slippery Slope of SharePoint Migrations
SPTechCon Austin - The Slippery Slope of SharePoint Migrations
 
aOS Canadian Tour Share point migration tips
aOS Canadian Tour Share point migration tipsaOS Canadian Tour Share point migration tips
aOS Canadian Tour Share point migration tips
 
SharePoint Development
SharePoint DevelopmentSharePoint Development
SharePoint Development
 
Designing your SharePoint Internet site: The basics
Designing your SharePoint Internet site: The basicsDesigning your SharePoint Internet site: The basics
Designing your SharePoint Internet site: The basics
 
Developing for SharePoint Online
Developing for SharePoint OnlineDeveloping for SharePoint Online
Developing for SharePoint Online
 
SharePoint Custom Development
SharePoint Custom DevelopmentSharePoint Custom Development
SharePoint Custom Development
 
SharePoint 2013 Dev Features
SharePoint 2013 Dev FeaturesSharePoint 2013 Dev Features
SharePoint 2013 Dev Features
 
What Makes Migrating to the Cloud Different Than On-Premises
What Makes Migrating to the Cloud Different Than On-PremisesWhat Makes Migrating to the Cloud Different Than On-Premises
What Makes Migrating to the Cloud Different Than On-Premises
 
What SharePoint is My Ferrari?
What SharePoint is My Ferrari? What SharePoint is My Ferrari?
What SharePoint is My Ferrari?
 
Introduction and What’s new in SharePoint 2013
Introduction and What’s new in SharePoint 2013Introduction and What’s new in SharePoint 2013
Introduction and What’s new in SharePoint 2013
 
SharePoint Online vs. On-Premise
SharePoint Online vs. On-PremiseSharePoint Online vs. On-Premise
SharePoint Online vs. On-Premise
 

More from Mark Rackley

SharePoint Conference North America - Converting your JavaScript to SPFX
SharePoint Conference North America - Converting your JavaScript to SPFXSharePoint Conference North America - Converting your JavaScript to SPFX
SharePoint Conference North America - Converting your JavaScript to SPFX
Mark Rackley
 
What IS SharePoint Development?
What IS SharePoint Development?What IS SharePoint Development?
What IS SharePoint Development?
Mark Rackley
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
Mark Rackley
 

More from Mark Rackley (11)

Column Formatter in SharePoint Online
Column Formatter in SharePoint OnlineColumn Formatter in SharePoint Online
Column Formatter in SharePoint Online
 
SharePoint Conference North America - Converting your JavaScript to SPFX
SharePoint Conference North America - Converting your JavaScript to SPFXSharePoint Conference North America - Converting your JavaScript to SPFX
SharePoint Conference North America - Converting your JavaScript to SPFX
 
A Power User's Introduction to jQuery Awesomeness in SharePoint
A Power User's Introduction to jQuery Awesomeness in SharePointA Power User's Introduction to jQuery Awesomeness in SharePoint
A Power User's Introduction to jQuery Awesomeness in SharePoint
 
Utilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done FasterUtilizing jQuery in SharePoint: Get More Done Faster
Utilizing jQuery in SharePoint: Get More Done Faster
 
Citizen Developers Intro to jQuery Customizations in SharePoint
Citizen Developers Intro to jQuery Customizations in SharePointCitizen Developers Intro to jQuery Customizations in SharePoint
Citizen Developers Intro to jQuery Customizations in SharePoint
 
A Power User's intro to jQuery awesomeness in SharePoint
A Power User's intro to jQuery awesomeness in SharePointA Power User's intro to jQuery awesomeness in SharePoint
A Power User's intro to jQuery awesomeness in SharePoint
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Wrapping your head around the SharePoint Beast (For the rest of us)
Wrapping your head around the SharePoint Beast (For the rest of us)Wrapping your head around the SharePoint Beast (For the rest of us)
Wrapping your head around the SharePoint Beast (For the rest of us)
 
What IS SharePoint Development?
What IS SharePoint Development?What IS SharePoint Development?
What IS SharePoint Development?
 
SPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery EssentialsSPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery Essentials
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 

Recently uploaded

Recently uploaded (20)

Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
The UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, OcadoThe UX of Automation by AJ King, Senior UX Researcher, Ocado
The UX of Automation by AJ King, Senior UX Researcher, Ocado
 
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
SOQL 201 for Admins & Developers: Slice & Dice Your Org’s Data With Aggregate...
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 

SharePoint & jQuery Guide - SPSTC 5/18/2013

  • 1. THE SHAREPOINT AND JQUERY GUIDE SharePoint Saturday Twin Cities May 18th, 2013 Mark Rackley mark.rackley@summit7systems.com
  • 2. » Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with companies such as Microsoft, Oracle and IBM. » Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and models to the solution provider industry. » Top 1% of Microsoft Partners Worldwide » Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year. » ~ 50% of Technical Staff hold US Government SECRET Clearances. » Service Disabled Veteran Owned Small Business (SDVOSB). Summit 7 systems is a premier provider of consulting and implementation services specializing on the Microsoft SharePoint Platform and FAST Enterprise Search. » Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with companies such as Microsoft, Oracle and IBM. » Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and models to the solution provider industry. » Top 1% of Microsoft Partners Worldwide » Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year. » ~ 50% of Technical Staff hold US Government SECRET Clearances. » Service Disabled Veteran Owned Small Business (SDVOSB).
  • 3. SERVICES SharePoint QuickStart Information Architecture and Governance Development Upgrade and Migration Branding and Design (User Experience) Web Content Management Design and Deployment SharePoint Search Custom Workflow or Web Part Development InfoPath Forms and Workflows Performance Baselines and Best Practices Optimization Mapping Business Process to Software Platforms Cloud Services Design and Provisioning Remote Support Contracts Compliance Quickstart SOFTWARE PLATFORMS FAST Enterprise Search SharePoint 2007 SharePoint 2010 SharePoint 2013 Office Platform Sitecore SOLUTION AREAS SharePoint Platform Solutions Enterprise Search Enterprise Content Management Internet / Web Content Management Extranet Solutions Intranet Solutions Business Process Management Enterprise Project Management Exchange Server SERVICES SharePoint QuickStart Information Architecture and Governance Development Upgrade and Migration Branding and Design (User Experience) Web Content Management Design and Deployment SharePoint Search Custom Workflow or Web Part Development InfoPath Forms and Workflows Performance Baselines and Best Practices Optimization Mapping Business Process to Software Platforms Cloud Services Design and Provisioning Remote Support Contracts Compliance Quickstart SOFTWARE PLATFORMS FAST Enterprise Search SharePoint 2007 SharePoint 2010 SharePoint 2013 Office Platform Sitecore SOLUTION AREAS SharePoint Platform Solutions Enterprise Search Enterprise Content Management Internet / Web Content Management Extranet Solutions Intranet Solutions Business Process Management Enterprise Project Management Exchange Server
  • 4. • 18+ years software architecture and development experience • SharePoint Junkie since 2007 • Event Organizer • Blogger, Writer, Speaker • Bacon aficionado MARK RACKLEY / SOLUTIONS ARCHITECT @mrackley http://www.sharepointhillbilly.com
  • 5. AGENDA • What is jQuery? Why SharePoint & jQuery? • SharePoint and jQuery Basics • Deploying / Maintaining • Development Basics • Third Party Libraries • Examples & Demos The SharePoint & jQuery Guide http://bit.ly/jQueryAndSP
  • 6. WHAT IS JQUERY? • JavaScript Utility Library • jQuery() or $() • Allows interaction and manipulation of the DOM after page is rendered • Can interact with other systems using Web Services • Supported by Microsoft • Part of “Client Side” Development
  • 7. WHY SHAREPOINT & JQUERY? • Fewer upgrade/deployment issues • Rapid deployment and modifications • Less “customization” • Improved visuals • Improved usability
  • 8. WHY SHAREPOINT & JQUERY? • Can replace the need for Visual Studio • Can replace the need for basic workflows • No points (shhhh… don’t tell the admins) • Can get around list view threshold
  • 9. JQUERY & SHAREPOINT BASICS • Scripts execute with same privileges as current user • Permissions cannot be elevated • Interact with SharePoint List data using Client Side Object Model (CSOM) or SPServices • View the DOM not the Page Source
  • 10. WHY I HATE JAVASCRIPT & JQUERY (SOME DAYS) • Too many optionsvar car = { color: “red”, make: “Jeep”, model: “wrangler” } var car = {}; car.color = “red”; car.make = “Jeep”; car.model=“wranger”; var car = {}; car*“color”+ = “red”; car*“make”+ = “Jeep”; car*“model”+ =“wranger”;
  • 11. WHY I HATE JAVASCRIPT & JQUERY (SOME DAYS) • Too many options • Debugging is painful • Performance can suffer • Inconsistent results on different browsers • Constant changes in the jQuery library • It CAN harm your farm!
  • 12. WHEN SHOULD YOU USE JQUERY? • Tightly controlled environments • Visuals or Usability are high priorities • Tight timeframes • Simple page and form modifications › Dynamic drop downs › Hiding page elements › Reading / populating fields • Why would you NOT use jQuery?
  • 13. WHEN SHOULD YOU QUESTION THE USE OF JQUERY? • Need pull a lot of data over the wire to work with • Iterating over many rows of list data • Extended business logic or proprietary business logic • Privileges need to be elevated • Need to support many different browsers
  • 14. DEPLOYMENT AND REFERENCE OPTIONS • Deployment Options • Document Library • File System • Content Delivery Network (CDN) • Reference Options • ScriptLink • Content Editor Web Part • Custom Action (deploys to Site Collection)
  • 16. CUSTOM ACTION <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction ScriptSrc="~sitecollection/SiteAssets/jquery.min.js" Location="ScriptLink" Sequence="100" > </CustomAction> </Elements>
  • 17. DEVELOPMENT & DEBUGGING • Development • Visual Studio • Web Essentials • TypeScript • SharePoint Designer • Notepad++ • Debugging • IE Developer Tools / Firebug • Fiddler • Alerts… alerts… alerts… • Avoid Console.log • Write scripts in small manageable chunks
  • 18. HOW ABOUT SOME BEST PRACTICES? • Use the Element’s ID when possible • Reduce DOM searches • Re-use code / Good coding practices • Minimize files • Use animations to hide slow performance • Delay loading of Selects until you need the data
  • 19. USING THIRD PARTY LIBRARIES Tips for selection and integration • Look for supported / documented libraries • Test in target browsers before implementing • Duplicate file structure • Test “vanilla” in SharePoint first
  • 20. USING THIRD PARTY LIBRARIES Some of my favorites • Content Slider - http://www.awkwardgroup.com/sandbox/awkward-showcase-a-jquery- plugin/ • Formatted Tables - http://www.datatables.net/ • Modal Window - http://www.ericmmartin.com/projects/simplemodal/ • SPServices - http://spservices.codeplex.com/ • Calendar - http://arshaw.com/fullcalendar/ • InfoPath Forms Alternative – http://forms7.codeplex.com
  • 21. BASICS / INTERACTING WITH FORMS
  • 22. BASICS Method Description $(document).ready(function($){}) Where code execution begins after page is loaded $(“#ElementID”) Returns element with given id $(“element.class”) Returns all elements of a particular class $(“div.myClass”) $(“Type*attrib=‘value’+”) Gets element of specific type and attribute value $(“input*Title=‘First Name’+”) .show(), .hide(), .toggle() Shows, hides, toggles .html() Gets the raw html for an element with tags .text() Contents of an element with HTML tags stripped out
  • 23. INTERACTING WITH SHAREPOINT FORMS Getting/Setting SharePoint Form Fields Text Boxes › $(“input*title=’My Text Field’+”).val(); Selects › $(“select*title=’My Choice’+”).val(mySelectValue); Checkboxes › $("input[title='My Check box']").removeAttr('checked'); › $("input[title='My Check box']").attr('checked','checked'); <input name="ctl00$m$g_a12c0b73_06fa_4552_a5af_b5d5fce55384$ctl00$ctl05$ctl03$ctl00$ctl00 $ctl04$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_m_g_a12c0b73_06fa_4552_a5af_b5d5fce55384_ctl00_ctl05_ctl03_ctl00_ctl00_ctl 04_ctl00_ctl00_TextField" title="E-mail Address" class=“ms-long ms-spellcheck-true" /> $(“input[title=‘E-mail Address’+”); //returns element $(“input”).each(function(), $(this).attr(“title”); // gets the value of the title attribute for all inputs });
  • 24. DEMO 1: BASICS / INTERACTING WITH FORMS
  • 25. READ LIST ITEMS WITH SPSERVICES
  • 26. <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($) { LoadSpeakers(); }); </script> <table id='speakerTable'><tr><th>Picture</th><th>Name</th><th>Blog</th></tr></table>
  • 27. <script type="text/javascript"> function LoadSpeakers(){ var listTitle = "Speakers"; var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'>0</Value></Neq></Where></Query>"; var camlViewFields = "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Blog' /><FieldRef Name='Picture' /></ViewFields>"; $().SPServices({ operation: "GetListItems", async: true, listName: listTitle, CAMLViewFields: camlViewFields, CAMLQuery: query, completefunc: function(xData, Status) { $(xData.responseXML).SPFilterNode("z:row").each(function() { var speakerName = ($(this).attr("ows_Title")); var picture = $(this).attr("ows_Picture").split(",")[0]; var blog = $(this).attr("ows_Blog").split(",")[0]; $("#speakerTable").append("<tr><td><img width='50' src='"+ picture +"'></td><td>"+speakerName +"</td><td>"+blog +"</td></tr>"); }); // end completefunc } }); // end SPS } </script> SPSERVICES READ LIST ITEMS
  • 28. DEMO 2: READ LIST ITEMS WITH SPSERVICES
  • 29. READ LIST ITEMS WITH CLIENT SIDE OBJECT MODEL
  • 30. <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script> <script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(LoadSpeakers, "sp.js"); </script> <table id='speakerTable'><tr><th>Picture</th><th>Name</th><th>Blog</th></tr></table>
  • 31. <script type="text/javascript"> function LoadSpeakers() { var listTitle = "Speakers"; context = SP.ClientContext.get_current(); var speakerList = context.get_web().get_lists().getByTitle(listTitle); var camlQuery = SP.CamlQuery.createAllItemsQuery(); this.listItems = speakerList.getItems(camlQuery); context.load(listItems); context.executeQueryAsync(ReadListItemSucceeded, ReadListItemFailed); } function ReadListItemSucceeded(sender, args) { var enumerator = listItems.getEnumerator(); while (enumerator.moveNext()) { var listItem = enumerator.get_current(); var blog = listItem.get_item('Blog').get_url(); var speakerName = listItem.get_item('Title'); var picture = listItem.get_item('Picture').get_url(); $("#speakerTable").append("<tr><td><img width='50' src='"+ picture +"'></td><td>"+speakerName +"</td><td>"+blog +"</td></tr>"); } } function ReadListItemFailed(sender, args) { alert('Request failed. ' + args.get_message() + 'n' + args.get_stackTrace()); } </script> CLIENT SIDE OBJECT MODEL READ LIST ITEMS
  • 32. DEMO 3: READ LIST ITEMS WITH CLIENT SIDE OBJECT MODEL
  • 34. SEARCHING DOM Method Description .split() lookUpFieldValue = “1;#Mark Rackley”; Var myArray = numbers.split(“;#”); myArray*1+ == “Mark Rackley” .replace() var myString = “This string has spaces”; var newString = myString.replace(/ /g,””); newString == “Thisstringhasspaces”; .contains() Check to see if a DOM element is within another DOM element .find() Get the child elements of current element, filtered by a selector Chaining: $("nobr b:contains('Sum= ')").html().split("= ")[1].replace(",","")
  • 35. DEMO 4: SEARCHING THE DOCUMENT OBJECT MODEL Tabbed Web Parts in SharePoint 2013 / Office 365 http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=42
  • 36. DEMO 5: BING MAP DEMO Integrating SharePoint and Bing Maps http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=19
  • 37. CREATING CUSTOM FORMS Forms7 – An InfoPath Forms Alternative https://forms7.codeplex.com/
  • 39. Special thanks to our sponsors…
  • 40. summit7systems summit7systems.com/blogs FOR MORE FROM SUMMIT 7 SYSTEMS… facebook.com/summit7systems @summit7systems summit 7 systems