SlideShare uma empresa Scribd logo
1 de 29
jQuery – What I Wish I Would Have Known a Year Ago…  Mark Rackley – Solutions Architect Email: mrackley@gmail.com Blog: http://www.sharepointhillbilly.com Twitter: http://www.twitter.com/mrackley
Agenda jQuery Overview jQuery & SharePoint – What’s the Point? Deployment, Maintenance, Upgrades SPServices Development & Debugging Examples 2
What is jQuery? JavaScript utility library - no cross browser issues if you are careful Quickly write interactive and USABLE applications You don’t have to deploy assemblies (perfect for tightly controlled environments)
What Skills do I need? JavaScript (duh) CSS A development background helps! 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
SharePoint & jQuery? Why? Resolves many SharePoint complaints without having to crack open Visual Studio “It looks like SharePoint” becomes “That’s SharePoint?” “SharePoint can’t do that out of the box” becomes “Sure, no problem” “That will take 3 weeks???” becomes “2 days? Awesome! I love you… here, please accept this bonus for being such a wonderful developer”
jQuery makes your SharePoint applications USABLE
Common Myths It’s not secure Busted… It uses SharePoint security. All scripts run with privleges of current user It doesn’t perform well Plausible… It performs very well if you use it correctly in the right situations I can’t elevate privileges if I need to Confirmed…
What about… I can’t interact with SharePoint Lists and Libraries Busted… You can call Web Services with JavaScript (SPServices is a wonderful jQuery library that wraps SharePoints Web Service calls) It has no real use in my environment because of “x” Busted… Quickly prototype and tweak web parts before writing in Visual Studio. In fact, in some environments it is the only development option.
Yeah But… It’s not deployable Create central script document library for jQuery scripts Upload new versions as needed Turn on versioning and store multiple versions Use metadata to keep track of script information Store on file system Deploy with solution package Increased performance of loading from file system
Okay… but… It’s not maintainable Script Placement Don’t put your script source in the CEWP Don’t hardcode scripts in your MasterPages Again… deploy scripts to central script document library or to file system with solution package If stored in doc lib, turn on versioning to easily roll-back if needed.
Moving Between Environments and Upgrading to 2010 It just works… (woo hoo) Uses list names and not GUIDs so no issues moving from dev to prod For the most part works identical in 2007 and 2010 (I’m sure there’s the occasional issue but I’ve never run into it). Might want to tweak in 2010 to take advantage of 2010 features (ribbin, modal pop-ups)
Okay then… jQuery must be the SharePoint Silver Bullet Busted… It does “expose” business logic to user if they dig around It executes on the client side and can perform slow if manipulating larges amounts of data Be extra careful for external facing applications You can’t do EVERYTHING with jQuerylike… Timer Jobs Workflows (although it can eliminate the need for some) Event Handlers Elevate Privliges Easily interact with all business systems
jQuery is another tool for the SharePoint Developer’s toolkitUnderstand the limitationsUse it wisely
Development Basics jQuery methods are executed using jQuery() or $() You don’t have to use $(document).ready()  Use $() directly $(‘#elementID’) to interact with any element $(‘#elementID’).val() gets values of inputs $(‘#elementID’).val([value]) sets the values of inputs $(‘#elementID’).html() gets the raw html within an element (great for divs, spans, tables, table cells, etc.) $(‘#elementID’).html(“<html text>”) to set raw html $(‘#elementID’).hide() and $(‘#elementID’).show()
Development Basics vardivs = $(“div”); Returns all divs in the document $(‘#element’).addClass(“className”); $(‘#element’).removeClass(“className”); $(‘#element’).attr(“attributeName”); $(‘#element’).attr(“attributeName”,”attributeValue”); GET O’REILLY’S JQUERY POCKET REFERENCE http://oreilly.com/catalog/0636920016182
More Dev Basics Each loops $('table[class="myTable"]').each( 		function () { 			$('#' + this.id).hide(); 		} ); CDATA is a life saver Wrap values in CDATA tags: "<![CDATA[" + data + "]]>"
SPServices jQuery library to execute SharePoint’s Web Services Get List Items Add/Update List Items Create lists, content types, site columns, etc. Create document library folders ,[object Object]
Get user groups and permissions
Potentially call ANY SharePoint Web Service,[object Object]
SPServicesGetListItems
SPServicesUpdateListItems
SPServices - FYI Use internal field names  Returned values have “ows_” in front of field names $(this).attr("ows_Title"); Lookup & People fields Value returned as “ID;#Value”  (1;#Field Value) Check for new item ID on item add to make sure item added correctly varnewID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
Development Tips Develop for performance Limit rows returned using CAML Avoid screen scraping (Use SPServices) Don’t call web services until the data is needed. Use those ID’s to your advantage <td id=‘ListName-4’> Attributes are awesome <input type="text" title="list title 4" id="4"> $('#4').attr("title");
Writing jQuery Pick whatever editor makes you happy… Visual Studio I don’t use it, so can’t speak to it Aptana (actual JavaScript IDE) Gives you some intellisense NotePad++ Good bracket matching which tends to bite you in the butt
Debugging… ugh.. It ain’t pretty Alerts.. Alerts.. Alerts.. Alerts… Developer Tools Set breakpoints Evaluate expressions and variables inline (like REAL debugging!) Firebug for Firefox  Considered to be best of the free tools out there IE Developer Tools  Comes installed on IE 8+
Debugging… Common Errors Usually it means your library didn’t get loaded Object Expected Object doesn’t support method Make sure you don’t load scripts more than once Null Object reference Check your braces Make sure you end lines with “;” Check for missing quotes When all else fails, delete your script and rebuild it slowly in chunks, testing as you go.
DEMOS
How to get it… jQuery http://jquery.com/ SPServices http://spservices.codeplex.com Super Awesome 3rd party libraries that integrate well Modal dialogs - http://www.ericmmartin.com/projects/simplemodal/ Calendar - http://arshaw.com/fullcalendar/ Charts - http://g.raphaeljs.com/
More jQuery Resources jQuery Pocket Reference http://oreilly.com/catalog/0636920016182 CSS Pocket Refernce http://oreilly.com/catalog/9780596515058/

Mais conteúdo relacionado

Mais procurados

Lesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ayLesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ay
Codecademy Ren
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
dominion
 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
testingphase
 
Monster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applicationsMonster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applications
Laurence Svekis ✔
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
rsnarayanan
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
Laila Buncab
 

Mais procurados (20)

Learn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUGLearn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUG
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Building Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan DieboltBuilding Smart Workflows - Dan Diebolt
Building Smart Workflows - Dan Diebolt
 
More object oriented development with Page Type Builder
More object oriented development with Page Type BuilderMore object oriented development with Page Type Builder
More object oriented development with Page Type Builder
 
Handlebars and Require.js
Handlebars and Require.jsHandlebars and Require.js
Handlebars and Require.js
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 
Lesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ayLesson 202 02 oct13-1800-ay
Lesson 202 02 oct13-1800-ay
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web ApplicationsMVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
 
J Query(04 12 2008) Foiaz
J Query(04 12 2008) FoiazJ Query(04 12 2008) Foiaz
J Query(04 12 2008) Foiaz
 
JavaScript DOM - Dynamic interactive Code
JavaScript DOM - Dynamic interactive CodeJavaScript DOM - Dynamic interactive Code
JavaScript DOM - Dynamic interactive Code
 
Monster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applicationsMonster JavaScript Course - 50+ projects and applications
Monster JavaScript Course - 50+ projects and applications
 
J Query The Write Less Do More Javascript Library
J Query   The Write Less Do More Javascript LibraryJ Query   The Write Less Do More Javascript Library
J Query The Write Less Do More Javascript Library
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
Google Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with CodeGoogle Apps Script for Beginners- Amazing Things with Code
Google Apps Script for Beginners- Amazing Things with Code
 
Getting Started with jQuery
Getting Started with jQueryGetting Started with jQuery
Getting Started with jQuery
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 

Semelhante a #SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..

Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
gouthamrv
 

Semelhante a #SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago.. (20)

Spsemea j query
Spsemea   j querySpsemea   j query
Spsemea j query
 
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
 
JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4JavaScript 2.0 in Dreamweaver CS4
JavaScript 2.0 in Dreamweaver CS4
 
jQuery
jQueryjQuery
jQuery
 
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
 
J Query
J QueryJ Query
J Query
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for Java
 
Building Web Hack Interfaces
Building Web Hack InterfacesBuilding Web Hack Interfaces
Building Web Hack Interfaces
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePoint
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Web 2.0
Web 2.0Web 2.0
Web 2.0
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
Ajax with DWR
Ajax with DWRAjax with DWR
Ajax with DWR
 

Mais de 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
 
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
Mark Rackley
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
Mark Rackley
 

Mais de 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
 
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
 
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
 
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
 
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 DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuerySPTechCon DevDays - SharePoint & jQuery
SPTechCon DevDays - SharePoint & jQuery
 
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
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
Using jQuery to Maximize Form Usability
Using jQuery to Maximize Form UsabilityUsing jQuery to Maximize Form Usability
Using jQuery to Maximize Form Usability
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
 
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
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 

#SPSEMEA SharePoint & jQuery - What I wish I would have known a year ago..

  • 1. jQuery – What I Wish I Would Have Known a Year Ago… Mark Rackley – Solutions Architect Email: mrackley@gmail.com Blog: http://www.sharepointhillbilly.com Twitter: http://www.twitter.com/mrackley
  • 2. Agenda jQuery Overview jQuery & SharePoint – What’s the Point? Deployment, Maintenance, Upgrades SPServices Development & Debugging Examples 2
  • 3. What is jQuery? JavaScript utility library - no cross browser issues if you are careful Quickly write interactive and USABLE applications You don’t have to deploy assemblies (perfect for tightly controlled environments)
  • 4. What Skills do I need? JavaScript (duh) CSS A development background helps! 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
  • 5. SharePoint & jQuery? Why? Resolves many SharePoint complaints without having to crack open Visual Studio “It looks like SharePoint” becomes “That’s SharePoint?” “SharePoint can’t do that out of the box” becomes “Sure, no problem” “That will take 3 weeks???” becomes “2 days? Awesome! I love you… here, please accept this bonus for being such a wonderful developer”
  • 6. jQuery makes your SharePoint applications USABLE
  • 7. Common Myths It’s not secure Busted… It uses SharePoint security. All scripts run with privleges of current user It doesn’t perform well Plausible… It performs very well if you use it correctly in the right situations I can’t elevate privileges if I need to Confirmed…
  • 8. What about… I can’t interact with SharePoint Lists and Libraries Busted… You can call Web Services with JavaScript (SPServices is a wonderful jQuery library that wraps SharePoints Web Service calls) It has no real use in my environment because of “x” Busted… Quickly prototype and tweak web parts before writing in Visual Studio. In fact, in some environments it is the only development option.
  • 9. Yeah But… It’s not deployable Create central script document library for jQuery scripts Upload new versions as needed Turn on versioning and store multiple versions Use metadata to keep track of script information Store on file system Deploy with solution package Increased performance of loading from file system
  • 10. Okay… but… It’s not maintainable Script Placement Don’t put your script source in the CEWP Don’t hardcode scripts in your MasterPages Again… deploy scripts to central script document library or to file system with solution package If stored in doc lib, turn on versioning to easily roll-back if needed.
  • 11. Moving Between Environments and Upgrading to 2010 It just works… (woo hoo) Uses list names and not GUIDs so no issues moving from dev to prod For the most part works identical in 2007 and 2010 (I’m sure there’s the occasional issue but I’ve never run into it). Might want to tweak in 2010 to take advantage of 2010 features (ribbin, modal pop-ups)
  • 12. Okay then… jQuery must be the SharePoint Silver Bullet Busted… It does “expose” business logic to user if they dig around It executes on the client side and can perform slow if manipulating larges amounts of data Be extra careful for external facing applications You can’t do EVERYTHING with jQuerylike… Timer Jobs Workflows (although it can eliminate the need for some) Event Handlers Elevate Privliges Easily interact with all business systems
  • 13. jQuery is another tool for the SharePoint Developer’s toolkitUnderstand the limitationsUse it wisely
  • 14. Development Basics jQuery methods are executed using jQuery() or $() You don’t have to use $(document).ready() Use $() directly $(‘#elementID’) to interact with any element $(‘#elementID’).val() gets values of inputs $(‘#elementID’).val([value]) sets the values of inputs $(‘#elementID’).html() gets the raw html within an element (great for divs, spans, tables, table cells, etc.) $(‘#elementID’).html(“<html text>”) to set raw html $(‘#elementID’).hide() and $(‘#elementID’).show()
  • 15. Development Basics vardivs = $(“div”); Returns all divs in the document $(‘#element’).addClass(“className”); $(‘#element’).removeClass(“className”); $(‘#element’).attr(“attributeName”); $(‘#element’).attr(“attributeName”,”attributeValue”); GET O’REILLY’S JQUERY POCKET REFERENCE http://oreilly.com/catalog/0636920016182
  • 16. More Dev Basics Each loops $('table[class="myTable"]').each( function () { $('#' + this.id).hide(); } ); CDATA is a life saver Wrap values in CDATA tags: "<![CDATA[" + data + "]]>"
  • 17.
  • 18. Get user groups and permissions
  • 19.
  • 22. SPServices - FYI Use internal field names Returned values have “ows_” in front of field names $(this).attr("ows_Title"); Lookup & People fields Value returned as “ID;#Value” (1;#Field Value) Check for new item ID on item add to make sure item added correctly varnewID = $(xData.responseXML).find("[nodeName=z:row]").attr("ows_ID");
  • 23. Development Tips Develop for performance Limit rows returned using CAML Avoid screen scraping (Use SPServices) Don’t call web services until the data is needed. Use those ID’s to your advantage <td id=‘ListName-4’> Attributes are awesome <input type="text" title="list title 4" id="4"> $('#4').attr("title");
  • 24. Writing jQuery Pick whatever editor makes you happy… Visual Studio I don’t use it, so can’t speak to it Aptana (actual JavaScript IDE) Gives you some intellisense NotePad++ Good bracket matching which tends to bite you in the butt
  • 25. Debugging… ugh.. It ain’t pretty Alerts.. Alerts.. Alerts.. Alerts… Developer Tools Set breakpoints Evaluate expressions and variables inline (like REAL debugging!) Firebug for Firefox Considered to be best of the free tools out there IE Developer Tools Comes installed on IE 8+
  • 26. Debugging… Common Errors Usually it means your library didn’t get loaded Object Expected Object doesn’t support method Make sure you don’t load scripts more than once Null Object reference Check your braces Make sure you end lines with “;” Check for missing quotes When all else fails, delete your script and rebuild it slowly in chunks, testing as you go.
  • 27. DEMOS
  • 28. How to get it… jQuery http://jquery.com/ SPServices http://spservices.codeplex.com Super Awesome 3rd party libraries that integrate well Modal dialogs - http://www.ericmmartin.com/projects/simplemodal/ Calendar - http://arshaw.com/fullcalendar/ Charts - http://g.raphaeljs.com/
  • 29. More jQuery Resources jQuery Pocket Reference http://oreilly.com/catalog/0636920016182 CSS Pocket Refernce http://oreilly.com/catalog/9780596515058/
  • 30. Questions? Mark Rackley mrackley@gmail.com www.twitter.com/mrackley www.sharepointhillbilly.com 29