Introduction to jQuery (for Drupal) Amit Asaravala “aasarava” on drupal.org.

Slides:



Advertisements
Similar presentations
Getting Started with jQuery. 1. Introduction to jQuery 2. Selection and DOM manipulation Contents 2.
Advertisements

JavaScript and AJAX Jonathan Foss University of Warwick
ENHANCE YOUR DASHBOARD WITH JQUERY
Javascript Introduction Norman White Material is from w3schools.com Go there to run examples interactively.
SE-2840 Dr. Mark L. Hornick1 jQuery. jQuery is a library of JavaScript functions Helps minimize the amount of JavaScript you have to write in order to:
Introduction to HTML5 Programming donghao. HTML5 is the New HTML Standard New Elements, Attributes. Full CSS3 Support Video and Audio 2D/3D Graphics Local.
JQuery & SharePoint San Antonio Users Group – September Meeting September 22, 2009 Microsoft SharePoint Server.
Building a Rich Internet Application with jQuery Ben Dewey twentysix New York Fill this space.
JQUERY/AJAX ALIREZA KHATAMIAN DELARAM YAZDANSEPAS.
Lecture 3B: Client-Side Scripting IT 202—Internet Applications Based on notes developed by Morgan Benton.
Philly.NET Hands-On jQuery + Plug-ins Bill Wolff, Rob Keiser.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Fundamentals, DOM, Events, AJAX, UI Doncho Minkov Telerik Corporation
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
JQuery CS 268. What is jQuery? From their web site:
PhpXperts What is jQuery Javascript Library Fast and concise Simplifies the interaction between HTML and JavaScript.
JavaScript & jQuery the missing manual Chapter 11
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
JQuery Adding behaviour…. Lecture Plan Review of last lesson Adding behaviour –click, mouseover Animation –fade, slideDown Navigation –parent, find, next.
Interacting with a Web Page using JavaScript Mat Kelly GTAI Presentation January 10, 2014.
13. jQuery See the official documentation at  See the terse API documentation at
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn.
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Animation & Effects Using JQuery. What is jQuery? jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use.
Introduction to Client Side Scripting CS Client Side Scripting Client side means the Browser is interpreting the script Script is downloaded with.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
JQuery Introduction © Copyright 2014, Fred McClurg All Rights Reserved.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
Web Programming Language Week 9 Dr. Ken Cosh Introducing jQuery.
Creating Dynamic Webpages
Intro to jQuery. What is jQuery? A JavaScript library Lightweight (about 31KB for the minified version) Simplifies HTML document traversing (DOM), event.
JavaScript Overview Developer Essentials How to Code Language Constructs The DOM concept- API, (use W3C model) Objects –properties Methods Events Applications;
IS2802 Introduction to Multimedia Applications for Business Lecture 07: Introduction to jQuery Rob Gleasure
Unit 13 –JQuery Basics Instructor: Brent Presley.
SHAREPOINT & JQUERY. Hi, my name and I am a product manager at lightning tools. I have been working with SharePoint for 5 years.
Craig Pelkie Copyright © 2015, Craig Pelkie ALL RIGHTS RESERVED Use RPG to Mobilize your IBM i.
JQUERY AND AJAX
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
SharePoint & jQuery. About me Phill Duffy – Product Manager at Lightning Tools Ltd – Author of ‘Pro SharePoint with jQuery’ – MCTS Application Developer.
JQuery is a fast, small, and feature-rich javascript library. It makes things like HTML document traversal and manipulation, event handling, animation,
JQuery Fundamentals Introduction Tutorial Videos
Unit M Programming Web Pages with
Creating customization with JS framework: Bootstrap
Ben Bimber, Ph.D. LabKey Software
Donna J. Kain, Clarkson University
Introduction to Web programming
Tutorial 6 Topic: jQuery and jQuery Mobile Li Xu
Fundamentals, DOM, Events, AJAX, UI
The Cliff Notes Version
Introduction to JavaScript
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
SEEM4570 Tutorial 5: jQuery + jQuery Mobile
Javascript and JQuery SRM DSC.
E-commerce Applications Development
Introduction to JavaScript
Chengyu Sun California State University, Los Angeles
CNIT 133 Interactive Web Pags – JavaScript and AJAX
Chengyu Sun California State University, Los Angeles
Web Programming and Design
Web Programming and Design
Presentation transcript:

Introduction to jQuery (for Drupal) Amit Asaravala “aasarava” on drupal.org

What is jQuery?

Magic

What is jQuery? A JavaScript library: Makes writing JavaScript a lot easier Makes writing cross-browser compatible JavaScript a lot easier Makes creating client-side interactivity a lot easier Makes AJAX a lot easier

How Do I Get jQuery?

For Drupal Sites: – D6  jQuery comes bundled – D7  jQuery comes bundled – Loaded automatically – Can use jquery_update module for newer vers. For Non-Drupal Sites: – – Get the “minified” version for production use

How Do I Use It?

How Do I Use It: Non-Drupal //your jquery code goes here. go crazy!

How Do I Use It: Drupal Theme Drupal 6: – Create a script.js file in your theme folder. – Your jQuery code goes in there. Drupal 7: – Edit your theme’s.info file – Add: scripts[] = script.js Reference:

How Do I Use It: Drupal Module 1.Create a mymodule.js file. 2.Use drupal_add_js() function in your module. mymodule_init() { $path = drupal_get_path(‘module’, ‘mymodule’); drupal_add_js($path. '/mymodule.js'); }

Yeah, But How Do I Use It?

Writing jQuery 1.Series of statements 2.Each statement is usually a 3-step process: 1.Select an element 2.Attach an event (optional) 3.Specify what happens “For this heading, when the user clicks on it, I want monkeys to fly across the page.”

3-Step Process 1.Select element: jQuery( ‘h2’ ) 2.Attach an event: jQuery( ‘h2’ ).click( ) 3.Specify what happens: jQuery( ‘h2’ ).click( monkeysFly );

Your Final Statement jQuery(‘h2’).click( monkeysFly );

$horthand $(‘h2’).click( monkeysFly ); see example

More Selectors $(‘input’).click( monkeysFly ); $(‘.title’).click( monkeysFly ); $(‘#form1 input’).click( monkeysFly ); $(‘#edit-title’).click( monkeysFly ); $(‘h2, h3,.title’).click( monkeysFly );

Monkey Code Inside script.js: $('h2').click( monkeysFly ); function monkeysFly() { $('img.monkey').fadeIn('slow'); }

Anonymous Functions $('h2').click( function() { $('img.monkey').fadeIn('slow'); } );

Anonymous Functions, 2 $('h2').click(function() { $('img.monkey').fadeIn('slow'); });

Wait ‘Til Browser is Ready $(document).ready(function() { $('h2').click(function() { $('img.monkey').fadeIn('slow'); });

D6: Wait ‘Til Browser is Ready Drupal.behaviors.demo = function(context) { $('h2‘, context).click(function() { $('img.monkey').fadeIn('slow'); }); };

D7: Wait ‘Til Browser is Ready Drupal.behaviors.demo = { attach: function(context, settings) { $('h2‘, context).click(function() { $('img.monkey').fadeIn('slow'); }); } };

Finding the Right jQuery Function Official: Handy:

Example: Dynamic Form Components Show character count as user is typing? No problem!

Example: Dynamic Form Components Let’s do this in a module countchars.module: function countchars_init() { $path = drupal_get_path(‘module’, ‘countchars’); drupal_add_js( $path. ‘/countchars.js’); }

Example: Dynamic Form Components countchars.js $(document).ready(function() { });

countchars.js $(document).ready(function() { $('#mytext').keyup( function() { });

countchars.js $(document).ready(function() { $('#mytext').after( ' characters: 0 ' ); $('#mytext').keyup( function() { });

Chaining $(document).ready(function() { $('#mytext').after( ' characters: 0 ' ).keyup( function() { });

countchars.js $(document).ready(function() { $('#mytext').after( ' characters: 0 ' ).keyup(function() { var count = $('#mytext').val().length; $('#chars').html( 'characters: ' + count ); });

$(this) $(document).ready(function() { $('#mytext').after( ' characters: 0 ' ).keyup(function() { var count = $(this).val().length; $('#chars').html( 'characters: ' + count ); });

Resources jquery.com -- main site jqueryui.com -- UI components Contact