SlideShare a Scribd company logo
1 of 67
jQuery for Drupal
What is jQuery?
What is jQuery?




 • http://jquery.com
What is jQuery?




 • http://jquery.com
 • “write less, do more”
Why is it so fun?
Why is it so fun?
• Removes cross-browser pain
Why is it so fun?
• Removes cross-browser pain
• Leverages your existing CSS
  knowledge
Why is it so fun?
• Removes cross-browser pain
• Leverages your existing CSS
  knowledge

• Animates elements on the page
Why is it so fun?
• Removes cross-browser pain
• Leverages your existing CSS
  knowledge

• Animates elements on the page
• Compact code
What’s it best at?
What’s it best at?
• Adding/Removing elements to/from
  the page
What’s it best at?
• Adding/Removing elements to/from
  the page
• Hiding/Showing elements
What’s it best at?
• Adding/Removing elements to/from
  the page
• Hiding/Showing elements
• Animating CSS transitions
What’s it best at?
• Adding/Removing elements to/from
  the page
• Hiding/Showing elements
• Animating CSS transitions
• Responding to clicks, hovers, focus
  events
What’s it best at?
• Adding/Removing elements to/from
  the page
• Hiding/Showing elements
• Animating CSS transitions
• Responding to clicks, hovers, focus
  events

• Selecting from and traversing the DOM
Core Drupal
  jQuery
Core Drupal
       jQuery
• Drupal adopted jQuery into core
  starting with Drupal 5
Core Drupal
       jQuery
• Drupal adopted jQuery into core
  starting with Drupal 5

• In /misc: drag-and-drop ordering,
  expandable textareas, collapsible
  fieldsets, autocomplete, persistent
  table headers etc.
Syntax
http://docs.jquery.com/Types#jQuery
Syntax
http://docs.jquery.com/Types#jQuery

• $(‘#page’).hide( );
Syntax
http://docs.jquery.com/Types#jQuery

• $(‘#page’).hide( );
• $(‘a’).addClass(‘test’);
Syntax
http://docs.jquery.com/Types#jQuery

• $(‘#page’).hide( );
• $(‘a’).addClass(‘test’);
• $(‘#page p’).click(function() {
    $(this).hide(‘slow’);
  });
Adding jQuery to
    a theme
Adding jQuery to
    a theme
• drupal_add_js(drupal_get_path(‘theme’,
  ‘MYTHEME’) . ‘/js/myfile.js’);
Adding jQuery to
    a theme
• drupal_add_js(drupal_get_path(‘theme’,
  ‘MYTHEME’) . ‘/js/myfile.js’);

• Add this to the top of template.php
  or in a specific theme function
Drupal behaviors
Sending settings
   to jQuery
Sending settings
   to jQuery
• Add setting from PHP
Sending settings
   to jQuery
• Add setting from PHP
Sending settings
   to jQuery
• Add setting from PHP

• Access Drupal.settings.myModule
  from within jQuery
jQuery Release
    Cycle
jQuery Release
      Cycle
• Drupal 7 has jQuery 1.4.4
jQuery Release
      Cycle
• Drupal 7 has jQuery 1.4.4
• Latest jQuery is 1.6.2
jQuery Release
      Cycle
• Drupal 7 has jQuery 1.4.4
• Latest jQuery is 1.6.2
• jQuery Update
Overriding JS
Overriding JS
• Override JS functions by redeclaring
  afterwards
Overriding JS
• Override JS functions by redeclaring
  afterwards

• ‘theme’ JS loads after ‘core’ and
  ‘module’ JS
Progressive
Enhancement
Progressive
    Enhancement
• Build the page without relying on
  jQuery
Progressive
    Enhancement
• Build the page without relying on
  jQuery

• Fancify for additional coolness
Progressive
    Enhancement
• Build the page without relying on
  jQuery

• Fancify for additional coolness
• Never use js to make changes that
  should be done in markup, styles,
  or PHP
AJAX
Form API
 #states
Common Use
   Cases
Common Use
       Cases
• Show more content on a page with
  hide/show, tabs, accordions,
  rotators, modals
Common Use
       Cases
• Show more content on a page with
  hide/show, tabs, accordions,
  rotators, modals

• Search bar with disappearing
  default value
Common Use
       Cases
• Show more content on a page with
  hide/show, tabs, accordions,
  rotators, modals

• Search bar with disappearing
  default value

• Slicker functionality with AJAX and
  AHAH
Popular Modules
Popular Modules
• Colorbox
Popular Modules
• Colorbox
• Quick Tabs
Popular Modules
• Colorbox
• Quick Tabs
• Views Slideshow
Popular Modules
• Colorbox
• Quick Tabs
• Views Slideshow
• Beauty Tips
Popular Modules
• Colorbox
• Quick Tabs
• Views Slideshow
• Beauty Tips
• Hierarchical
  Select
Popular Modules
• Colorbox        • Views UI
• Quick Tabs
• Views Slideshow
• Beauty Tips
• Hierarchical
 Select
Popular Modules
• Colorbox        • Views UI
• Quick Tabs      • FullCalendar
• Views Slideshow
• Beauty Tips
• Hierarchical
  Select
Popular Modules
• Colorbox        • Views UI
• Quick Tabs      • FullCalendar
• Views Slideshow • Views
                    Accordion
• Beauty Tips
• Hierarchical
  Select
Popular Modules
• Colorbox          • Views UI
• Quick Tabs        • FullCalendar
• Views Slideshow   • Views
                      Accordion
• Beauty Tips
• Hierarchical      • Feedback
  Select
jQuery UI
jQuery UI
jQuery UI

• Used to be jquery_ui module
jQuery UI

• Used to be jquery_ui module
• In Drupal 7 core!
Resources & Tools
Resources & Tools
• http://api.jquery.com
Resources & Tools
• http://api.jquery.com
• Firebug for Firefox
Resources & Tools
• http://api.jquery.com
• Firebug for Firefox
• http://drupal.org/node/171213
Demo
Demo
• Let’s do this.

More Related Content

What's hot

WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
Patrick Lauke
 
Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012
livelogos
 

What's hot (20)

Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
WAI-ARIA
WAI-ARIAWAI-ARIA
WAI-ARIA
 
Website Review with Screen Reader vs. SiteImprove
Website Review with Screen Reader vs. SiteImproveWebsite Review with Screen Reader vs. SiteImprove
Website Review with Screen Reader vs. SiteImprove
 
Best SEO Training Institute in North Delhi
Best SEO Training Institute in North DelhiBest SEO Training Institute in North Delhi
Best SEO Training Institute in North Delhi
 
WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
WAI-ARIA - an introduction to accessible rich internet applications (1 day wo...
 
jQTouch and Titanium
jQTouch and TitaniumjQTouch and Titanium
jQTouch and Titanium
 
Styling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS EditionStyling Components with JavaScript: MelbCSS Edition
Styling Components with JavaScript: MelbCSS Edition
 
Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012Sizzle jQCon San Francisco 2012
Sizzle jQCon San Francisco 2012
 
jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013jQuery Conference Austin Sept 2013
jQuery Conference Austin Sept 2013
 
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
 
2011 - SharePoint + jQuery
2011 - SharePoint + jQuery2011 - SharePoint + jQuery
2011 - SharePoint + jQuery
 
Styling components with JavaScript
Styling components with JavaScriptStyling components with JavaScript
Styling components with JavaScript
 
Wheel.js
Wheel.jsWheel.js
Wheel.js
 
WP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post TypesWP 101 - Custom Fields & Post Types
WP 101 - Custom Fields & Post Types
 
CSS架構如何加速功能開發
CSS架構如何加速功能開發CSS架構如何加速功能開發
CSS架構如何加速功能開發
 
HTML5: Introduction
HTML5: IntroductionHTML5: Introduction
HTML5: Introduction
 
WP101 - Themes and Plugins
WP101 - Themes and PluginsWP101 - Themes and Plugins
WP101 - Themes and Plugins
 
WP 101 - WordPress Basics
WP 101 - WordPress BasicsWP 101 - WordPress Basics
WP 101 - WordPress Basics
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Becoming a more productive Rails Developer
Becoming a more productive Rails DeveloperBecoming a more productive Rails Developer
Becoming a more productive Rails Developer
 

Viewers also liked (6)

LEMON - On Drupal diseases and cures
LEMON - On Drupal diseases and curesLEMON - On Drupal diseases and cures
LEMON - On Drupal diseases and cures
 
Custom Field Formatters
Custom Field FormattersCustom Field Formatters
Custom Field Formatters
 
jQuery for Drupal
jQuery for DrupaljQuery for Drupal
jQuery for Drupal
 
Semantic Site Building (Drupal 7)
Semantic Site Building (Drupal 7)Semantic Site Building (Drupal 7)
Semantic Site Building (Drupal 7)
 
Enas Fares
Enas FaresEnas Fares
Enas Fares
 
Rays Of Light Final Kim Drynan
Rays Of Light Final   Kim DrynanRays Of Light Final   Kim Drynan
Rays Of Light Final Kim Drynan
 

Similar to Intro to jQuery for Drupal

SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
Mark Rackley
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
elliando dias
 
J query presentation
J query presentationJ query presentation
J query presentation
akanksha17
 
J query presentation
J query presentationJ query presentation
J query presentation
sawarkar17
 

Similar to Intro to jQuery for Drupal (20)

jQuery for Drupal
jQuery for DrupaljQuery for Drupal
jQuery for Drupal
 
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)
 
SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014SharePoint & jQuery Guide - SPSNashville 2014
SharePoint & jQuery Guide - SPSNashville 2014
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
 
SPSHawaii: Navigation: A Step Towards Success in SharePoint
SPSHawaii:  Navigation: A Step Towards Success in SharePointSPSHawaii:  Navigation: A Step Towards Success in SharePoint
SPSHawaii: Navigation: A Step Towards Success in SharePoint
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
 
Web designing course content
Web designing course contentWeb designing course content
Web designing course content
 
UF HTML Template Presentation
UF HTML Template PresentationUF HTML Template Presentation
UF HTML Template Presentation
 
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
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Progressively Enhancing WordPress Themes
Progressively Enhancing WordPress ThemesProgressively Enhancing WordPress Themes
Progressively Enhancing WordPress Themes
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Windycityrails page performance
Windycityrails page performanceWindycityrails page performance
Windycityrails page performance
 
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
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
J query presentation
J query presentationJ query presentation
J query presentation
 
J query presentation
J query presentationJ query presentation
J query presentation
 
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
Rich and Beautiful: Making Attractive Apps in HTML5 [Wpg 2013]
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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
 

Intro to jQuery for Drupal

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. As a simple example lets look at how you'd go about finding all the https links on a page and adding some additional text marking them as secure, turning <a href="https://example.com">Example</a> into <a href="https://example.com">Example (Secure!)</a>. This should make the importance of only running the code once apparent, if our code ran twice the link would end up reading "Example (Secure!) (Secure!)".\n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n