SlideShare ist ein Scribd-Unternehmen logo
1 von 34
SharePoint & jQuery Essentials

     SharePoint Saturday St. Louis
          January 12th, 2013
             Mark Rackley
  mark.rackley@summit7systems.com
Housekeeping
• Please remember to submit your session
  evaluation for each session you attend
• Follow SharePoint Saturday St. Louis on
  Twitter @spsstl and hashtag #spsstl




                                   2   | SharePoint Saturday St. Louis 2012
Thanks to Our Sponsors!




                    3   | SharePoint Saturday St. Louis 2012
About Mark Rackley
•   Solutions Architect & Developer at Summit 7 Systems
•   17+ years software architecture and development experience
•   Blogger, Writer, Speaker
•   mark.rackley@summit7systems.com
•   @mrackley
•   http://sharepointhillbilly.com
Agenda
•   SharePoint & jQuery’s history
•   jQuery Overview
•   When to use jQuery / When not to
•   Deployment & Maintenance
•   Development Basics
•   Using Third Party Libraries

            The SharePoint & jQuery Guide
              http://bit.ly/jQueryAndSP
SharePoint & jQuery’s Courtship
• What is jQuery?
  – JavaScript utility library supported by Microsoft
  – Allows you to interact with a page AFTER it is
    rendered using the DOM
• What’s the history?
  –   Snubbed in SharePoint 2007
  –   Tolerated in SharePoint 2010
  –   Embraced in SharePoint 2013
  –   It’s the future
jQuery Overview

• What skills do you need?
  – JavaScript
  – CSS, XML, JSON
  – A development background
     • It IS code
     • Uses development constructs
     • If you can’t write code, your ability to do magic will be limited to what
       you can copy/paste
  – CAML, CAML, CAML… Sorry…
  – Ability to think outside the box
     • Use all the pieces together
Crappy Abstruse Markup Language
'<Query><Where>
       <And>
              <Geq><FieldRef Name="StartDate" /><Value
IncludeTimeValue="TRUE"
Type="DateTime">'+startDate+'</Value></Geq>
              <Leq><FieldRef Name="EndDate" /><Value
IncludeTimeValue="TRUE"
Type="DateTime">'+endDate+'</Value></Leq>
       </And>
</Where></Query>',
SharePoint & jQuery? Why?
•   Fewer upgrade/deployment issues
•   Less “customization”
•   Improved visuals
•   Improved usability
•   Rapid deployment and modifications
SharePoint & jQuery? Why?
• Can replace the need for Visual Studio for
  some web parts
• Can replace the need for basic workflows
• No points (shhhh… don’t tell the admins)
• Can get around list view threshold
jQuery makes your SharePoint
applications USABLE and allows you to
get your work done NOW
jQuery Overview
• Busting jQuery Mtyhs
  – It’s not secure
     • BUSTED
         – It uses SharePoint’s security
         – Scripts execute with privileges of current user
  – It doesn’t perform well
     • BUSTED
         – Reduce page loads
         – Delay data queries
  – You can’t elevate privileges
     • CONFIRMED
         – Thank God
jQuery Overview

• Why I hate jQuery (some days)
  –   Too many options
  –   Debugging
  –   It can perform horribly
  –   Inconsistent results
  –   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
 • Deployment Options
   – Document Library
      • Easily modify scripts
      • Keep track of changes with Metadata
      • Recover from screw ups with Versioning
   – File System
      • Deployed with a WSP (don’t think of manually copying)
      • Not an option for Office 365 or hosted SharePoint 2010
   – Content Delivery Network (CDN)
Document Library
Reference Options
<script type="text/javascript" src="/SiteAssets/jquery.min.js"></script>



  • ScriptLink
              •   MasterPages, Delegate Controls, Web Parts, Controls, Custom Pages
              •   Ensures Script is not loaded multiple times
              •   Renders in the correct place in the markup
              •   Need Visual Studio or SPD
              •   More upfront work
  • Content Editor Web Part (CEWP)
              • Quick & Easy
              • Don’t have to deploy anything
              • Adds CEWP overhead
Reference Options

• Custom Action
       • Loads Script for entire Site Collection
       • Works in sandbox

<?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
• Development Tools
  – IDE
    • Visual Studio
    • Notepad++
    • SharePoint Designer
  – Debugging
    • IE Developer Tools / Chrome Debugger / Firebug
    • Fiddler
    • Alerts… lots and lots of alerts
    • Avoid Console.log (or use it wisely)
jQuery Overview - JavaScript
“Objects”
var car = {                         var car = {};
    color: “red”,                   car.color = “red”;
    make: “Jeep”,                   car.make = “Jeep”;
    model: “wrangler”               car.model=“wranger”;
}
                  var car = {};
                  car*“color”+ = “red”;
                  car*“make”+ = “Jeep”;
                  car*“model”+ =“wranger”;
jQuery Overview – Common Usage
  Method                             Description

  $(document).ready(function($){})   Where code execution begins after page is loaded

  $(“#ElementID”)                    Returns element with given id

   $(“element.class”)
<input                            Returns all elements of a particular class
                                  $(“div.myClass”)
name="ctl00$m$g_a12c0b73_06fa_4552_a5af_b5d5fce55384$ctl00$ctl05$ctl03$ctl00$ctl00
$ctl04$ctl00$ctl00$TextField" type="text" maxlength="255" attribute value $(“input*Title=‘First
   $(“Type*attrib=‘value’+”)      Gets element of specific type and
                                  Name’+”)
id="ctl00_m_g_a12c0b73_06fa_4552_a5af_b5d5fce55384_ctl00_ctl05_ctl03_ctl00_ctl00_ctl0
   .show(), .hide(), .toggle()    Shows, hides, toggles
4_ctl00_ctl00_TextField" title="E-mail Address" class=“ms-long ms-spellcheck-true" />
  .html()                            Gets the raw html for an element with tags
$(“input[title=‘E-mail Address’+”); Contents of an element with HTML tags stripped out
    .text()                             //returns element
$(“input”).each(function(),
            $(this).attr(“title”); // gets the value of the title attribute for all inputs
});
jQuery Overview – Common Methods

 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:
$("#WebPartWPDnn").find("nobr b:contains('Sum = ')").html().split(" = ")[1].replace(",","");
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');

The SharePoint & jQuery Guide http://bit.ly/jQueryAndSP
Interacting With
SharePoint List Data
When to Choose SPServices vs. the Client Object Model
http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=15
CSOM vs. SPServices

Functionality                      CSOM   SPServices
SharePoint 2007                    No     Yes
SharePoint 2010/2013               Yes    Yes
Anonymous Access                   No     Yes
Cross Site / Cross Domain Access   No     Yes
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/
DEMOS – AND NIFTY STUFF
So, what’s the deal?
”Fast Food” Development

•   You don’t have to be a SharePoint Guru
•   It’s Cheap
•   It’s Quick
•   It’s Easy
•   It gets the job done
”Fast Food” Development

•   Don’t abuse it, You’ll pay for it later
•   Limited choices
•   There are healthier options
•   Adds page bloat
•   Can slow your performance
Questions?

     Don’t drink the
     haterade…



Mark Rackley
mark.rackley@summit7systems.com
www.twitter.com/mrackley
www.sharepointhillbilly.com

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryZeeshan Khan
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do MoreRemy Sharp
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQueryGunjan Kumar
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introductionTomi Juhola
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePointMarc D Anderson
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgetsvelveeta_512
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingDoug Neiner
 
Nothing Hard Baked: Designing the Inclusive Web
Nothing Hard Baked: Designing the Inclusive WebNothing Hard Baked: Designing the Inclusive Web
Nothing Hard Baked: Designing the Inclusive Webcolinbdclark
 
User Interface Development with jQuery
User Interface Development with jQueryUser Interface Development with jQuery
User Interface Development with jQuerycolinbdclark
 

Was ist angesagt? (20)

Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
Jquery
JqueryJquery
Jquery
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
 
jQuery Introduction
jQuery IntroductionjQuery Introduction
jQuery Introduction
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
Introduction to jQuery
Introduction to jQueryIntroduction to jQuery
Introduction to jQuery
 
jQuery
jQueryjQuery
jQuery
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
SharePointfest Denver - A jQuery Primer for SharePoint
SharePointfest Denver -  A jQuery Primer for SharePointSharePointfest Denver -  A jQuery Primer for SharePoint
SharePointfest Denver - A jQuery Primer for SharePoint
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
jQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and BlingjQuery: Nuts, Bolts and Bling
jQuery: Nuts, Bolts and Bling
 
Nothing Hard Baked: Designing the Inclusive Web
Nothing Hard Baked: Designing the Inclusive WebNothing Hard Baked: Designing the Inclusive Web
Nothing Hard Baked: Designing the Inclusive Web
 
User Interface Development with jQuery
User Interface Development with jQueryUser Interface Development with jQuery
User Interface Development with jQuery
 
jQuery Presentasion
jQuery PresentasionjQuery Presentasion
jQuery Presentasion
 
jQuery quick tuts
jQuery quick tutsjQuery quick tuts
jQuery quick tuts
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 

Andere mochten auch

SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...
SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...
SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...Marc D Anderson
 
SEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePointSEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePointMarc D Anderson
 
Oslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose ItOslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose ItMarc D Anderson
 
SharePoint Evolutions 2015 - Moving from SOAP to REST
SharePoint Evolutions 2015 - Moving from SOAP to RESTSharePoint Evolutions 2015 - Moving from SOAP to REST
SharePoint Evolutions 2015 - Moving from SOAP to RESTMarc D Anderson
 
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...Marc D Anderson
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 

Andere mochten auch (7)

SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...
SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...
SharePoint Tech Fest Houston 2015 - Creating a Great User Experience in Share...
 
SEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePointSEF2013 - A jQuery Primer for SharePoint
SEF2013 - A jQuery Primer for SharePoint
 
Oslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose ItOslo SP User Group - Content Types - Love Them or Lose It
Oslo SP User Group - Content Types - Love Them or Lose It
 
SharePoint Evolutions 2015 - Moving from SOAP to REST
SharePoint Evolutions 2015 - Moving from SOAP to RESTSharePoint Evolutions 2015 - Moving from SOAP to REST
SharePoint Evolutions 2015 - Moving from SOAP to REST
 
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
Unity Connect Haarlem 2016 - The Lay of the Land of Client-Side Development c...
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 

Ähnlich wie SharePoint and jQuery Essentials

SPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery EssentialsSPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery EssentialsMark Rackley
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointMark Rackley
 
SPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQueryMark Rackley
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsMark Rackley
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideMark Rackley
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownMark Rackley
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery GuideMark Rackley
 
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 - SPTechConSPTechCon
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014Mark Rackley
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointMark Rackley
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationSean Burgess
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012crokitta
 
2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptxLe Hung
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizationsChris Love
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
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 FasterMark Rackley
 

Ähnlich wie SharePoint and jQuery Essentials (20)

SPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery EssentialsSPSTC - SharePoint & jQuery Essentials
SPSTC - SharePoint & jQuery Essentials
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
 
SPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuery
 
SPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentialsSPTechCon - Share point and jquery essentials
SPTechCon - Share point and jquery essentials
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have known
 
The SharePoint & jQuery Guide
The SharePoint & jQuery GuideThe SharePoint & jQuery Guide
The SharePoint & jQuery Guide
 
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
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
SPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePointSPTechCon 2014 How to develop and debug client side code in SharePoint
SPTechCon 2014 How to develop and debug client side code in SharePoint
 
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD CombinationLotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
Lotusphere 2012 Speedgeeking - jQuery & Domino, a RAD Combination
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
 
2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx2a-JQuery AJAX.pptx
2a-JQuery AJAX.pptx
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
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
 
bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 

Mehr von Mark Rackley

Column Formatter in SharePoint Online
Column Formatter in SharePoint OnlineColumn Formatter in SharePoint Online
Column Formatter in SharePoint OnlineMark 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 SPFXMark Rackley
 
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 SharePointMark Rackley
 
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 SharePointMark Rackley
 
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 SharePointMark Rackley
 
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 SharePointMark Rackley
 
#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...Mark Rackley
 
Introduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPathIntroduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPathMark Rackley
 
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsSPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsMark Rackley
 
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 librariesMark Rackley
 
SPTechCon Dev Days - Third Party jQuery Libraries
SPTechCon Dev Days - Third Party jQuery LibrariesSPTechCon Dev Days - Third Party jQuery Libraries
SPTechCon Dev Days - Third Party jQuery LibrariesMark Rackley
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityMark Rackley
 
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/14Mark Rackley
 
SharePoint REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOMMark Rackley
 
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 WorkshopMark Rackley
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery GuideMark Rackley
 
SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013 SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013 Mark Rackley
 
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 itMark Rackley
 
What is SharePoint Development??
What is SharePoint Development??What is SharePoint Development??
What is SharePoint Development??Mark Rackley
 
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)Mark Rackley
 

Mehr von Mark Rackley (20)

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
 
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
 
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
 
#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...
 
Introduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPathIntroduction to StratusForms #SayNoToInfoPath
Introduction to StratusForms #SayNoToInfoPath
 
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint LimitationsSPTechCon Boston 2015 - Overcoming SharePoint Limitations
SPTechCon Boston 2015 - Overcoming SharePoint Limitations
 
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
 
SPTechCon Dev Days - Third Party jQuery Libraries
SPTechCon Dev Days - Third Party jQuery LibrariesSPTechCon Dev Days - Third Party jQuery Libraries
SPTechCon Dev Days - Third Party jQuery Libraries
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form Usability
 
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 REST vs CSOM
SharePoint REST vs CSOMSharePoint REST vs CSOM
SharePoint REST vs CSOM
 
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
 
(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide(Updated) SharePoint & jQuery Guide
(Updated) SharePoint & jQuery Guide
 
SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013 SharePoint & jQuery Guide - SPSTC 5/18/2013
SharePoint & jQuery Guide - SPSTC 5/18/2013
 
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
 
What is SharePoint Development??
What is SharePoint Development??What is SharePoint Development??
What is SharePoint Development??
 
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)
 

SharePoint and jQuery Essentials

  • 1. SharePoint & jQuery Essentials SharePoint Saturday St. Louis January 12th, 2013 Mark Rackley mark.rackley@summit7systems.com
  • 2. Housekeeping • Please remember to submit your session evaluation for each session you attend • Follow SharePoint Saturday St. Louis on Twitter @spsstl and hashtag #spsstl 2 | SharePoint Saturday St. Louis 2012
  • 3. Thanks to Our Sponsors! 3 | SharePoint Saturday St. Louis 2012
  • 4. About Mark Rackley • Solutions Architect & Developer at Summit 7 Systems • 17+ years software architecture and development experience • Blogger, Writer, Speaker • mark.rackley@summit7systems.com • @mrackley • http://sharepointhillbilly.com
  • 5. Agenda • SharePoint & jQuery’s history • jQuery Overview • When to use jQuery / When not to • Deployment & Maintenance • Development Basics • Using Third Party Libraries The SharePoint & jQuery Guide http://bit.ly/jQueryAndSP
  • 6. SharePoint & jQuery’s Courtship • What is jQuery? – JavaScript utility library supported by Microsoft – Allows you to interact with a page AFTER it is rendered using the DOM • What’s the history? – Snubbed in SharePoint 2007 – Tolerated in SharePoint 2010 – Embraced in SharePoint 2013 – It’s the future
  • 7. jQuery Overview • What skills do you need? – JavaScript – CSS, XML, JSON – A development background • It IS code • Uses development constructs • If you can’t write code, your ability to do magic will be limited to what you can copy/paste – CAML, CAML, CAML… Sorry… – Ability to think outside the box • Use all the pieces together
  • 8. Crappy Abstruse Markup Language '<Query><Where> <And> <Geq><FieldRef Name="StartDate" /><Value IncludeTimeValue="TRUE" Type="DateTime">'+startDate+'</Value></Geq> <Leq><FieldRef Name="EndDate" /><Value IncludeTimeValue="TRUE" Type="DateTime">'+endDate+'</Value></Leq> </And> </Where></Query>',
  • 9. SharePoint & jQuery? Why? • Fewer upgrade/deployment issues • Less “customization” • Improved visuals • Improved usability • Rapid deployment and modifications
  • 10. SharePoint & jQuery? Why? • Can replace the need for Visual Studio for some web parts • Can replace the need for basic workflows • No points (shhhh… don’t tell the admins) • Can get around list view threshold
  • 11. jQuery makes your SharePoint applications USABLE and allows you to get your work done NOW
  • 12. jQuery Overview • Busting jQuery Mtyhs – It’s not secure • BUSTED – It uses SharePoint’s security – Scripts execute with privileges of current user – It doesn’t perform well • BUSTED – Reduce page loads – Delay data queries – You can’t elevate privileges • CONFIRMED – Thank God
  • 13. jQuery Overview • Why I hate jQuery (some days) – Too many options – Debugging – It can perform horribly – Inconsistent results – Changes in the jQuery library – It CAN harm your farm!
  • 14. 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?
  • 15. 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
  • 16. Deployment • Deployment Options – Document Library • Easily modify scripts • Keep track of changes with Metadata • Recover from screw ups with Versioning – File System • Deployed with a WSP (don’t think of manually copying) • Not an option for Office 365 or hosted SharePoint 2010 – Content Delivery Network (CDN)
  • 18. Reference Options <script type="text/javascript" src="/SiteAssets/jquery.min.js"></script> • ScriptLink • MasterPages, Delegate Controls, Web Parts, Controls, Custom Pages • Ensures Script is not loaded multiple times • Renders in the correct place in the markup • Need Visual Studio or SPD • More upfront work • Content Editor Web Part (CEWP) • Quick & Easy • Don’t have to deploy anything • Adds CEWP overhead
  • 19. Reference Options • Custom Action • Loads Script for entire Site Collection • Works in sandbox <?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>
  • 20. Development • Development Tools – IDE • Visual Studio • Notepad++ • SharePoint Designer – Debugging • IE Developer Tools / Chrome Debugger / Firebug • Fiddler • Alerts… lots and lots of alerts • Avoid Console.log (or use it wisely)
  • 21. jQuery Overview - JavaScript “Objects” var car = { var car = {}; color: “red”, car.color = “red”; make: “Jeep”, car.make = “Jeep”; model: “wrangler” car.model=“wranger”; } var car = {}; car*“color”+ = “red”; car*“make”+ = “Jeep”; car*“model”+ =“wranger”;
  • 22. jQuery Overview – Common Usage Method Description $(document).ready(function($){}) Where code execution begins after page is loaded $(“#ElementID”) Returns element with given id $(“element.class”) <input Returns all elements of a particular class $(“div.myClass”) name="ctl00$m$g_a12c0b73_06fa_4552_a5af_b5d5fce55384$ctl00$ctl05$ctl03$ctl00$ctl00 $ctl04$ctl00$ctl00$TextField" type="text" maxlength="255" attribute value $(“input*Title=‘First $(“Type*attrib=‘value’+”) Gets element of specific type and Name’+”) id="ctl00_m_g_a12c0b73_06fa_4552_a5af_b5d5fce55384_ctl00_ctl05_ctl03_ctl00_ctl00_ctl0 .show(), .hide(), .toggle() Shows, hides, toggles 4_ctl00_ctl00_TextField" title="E-mail Address" class=“ms-long ms-spellcheck-true" /> .html() Gets the raw html for an element with tags $(“input[title=‘E-mail Address’+”); Contents of an element with HTML tags stripped out .text() //returns element $(“input”).each(function(), $(this).attr(“title”); // gets the value of the title attribute for all inputs });
  • 23. jQuery Overview – Common Methods 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: $("#WebPartWPDnn").find("nobr b:contains('Sum = ')").html().split(" = ")[1].replace(",","");
  • 24. 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'); The SharePoint & jQuery Guide http://bit.ly/jQueryAndSP
  • 25. Interacting With SharePoint List Data When to Choose SPServices vs. the Client Object Model http://www.sharepointhillbilly.com/Lists/Posts/Post.aspx?ID=15
  • 26. CSOM vs. SPServices Functionality CSOM SPServices SharePoint 2007 No Yes SharePoint 2010/2013 Yes Yes Anonymous Access No Yes Cross Site / Cross Domain Access No Yes
  • 27. 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
  • 28. 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
  • 29. 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/
  • 30. DEMOS – AND NIFTY STUFF
  • 32. ”Fast Food” Development • You don’t have to be a SharePoint Guru • It’s Cheap • It’s Quick • It’s Easy • It gets the job done
  • 33. ”Fast Food” Development • Don’t abuse it, You’ll pay for it later • Limited choices • There are healthier options • Adds page bloat • Can slow your performance
  • 34. Questions? Don’t drink the haterade… Mark Rackley mark.rackley@summit7systems.com www.twitter.com/mrackley www.sharepointhillbilly.com