intro to jquery - tulsa ruby group

17
Intro to jQuery Presented by Brad Vernon [email protected] Tulsa.rb Group Oct. 1, 2007

Upload: brad-vernon

Post on 17-May-2015

2.567 views

Category:

Technology


1 download

DESCRIPTION

Intro to jQuery Presented at Tulsa.rb Group, Oct 1, 2007

TRANSCRIPT

Page 1: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

Presented by

Brad [email protected]

Tulsa.rb Group Oct. 1, 2007

Page 2: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• JavaScript library/framework• Very small footprint

– 26k minified– 14k minified and gzipped

• Cross-browser compatible– IE 5.5+, FF 1.5+, Safari 2.0+, Opera 9+

• Created by John Resig in Jan. 2006• Open source

What is jQuery?

April 12, 2023 2

Page 3: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Built with plug-in architecture

• Incredibly easy to learn / use

• Can be used inline or external .js file

• Chaining methods (my favorite feature)

• CSS v1-3 compatible

• Namespacing (plays nice with others)

• Great docs and community

What is jQuery?

April 12, 2023 3

Page 4: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Digg• MSNBC• Wordpress.com and stand-alone app• Amazon• Quicken• Salesforce• SourceForge• Pandora• Me• Many, many, more…

Who is using jQuery?

April 12, 2023 4

Page 5: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Magical functions allow for this:

(function($) { // $ is a reference to jQuery

})(jQuery);

• Uses CSS to select:

$(“.classname”).click().

Attaches event to any object with a class of “classname”

How does it work?

April 12, 2023 5

Page 6: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• click() / dblclick()

• ajax() – GET or POST – JSON, html, xml

• hover()

• trigger()

• and more

Events

April 12, 2023 6

Page 7: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• find() – find all of what on page

• filter() – ignore what

• each() – very powerful

• is() / hasClass() / not()

Traversing

April 12, 2023 7

Page 8: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Some effects built in:– hide/show– fadeIn/fadeOut– slideUp/slideDown– toggle

• More effects via plug-ins (jQuery UI)

Effects

April 12, 2023 8

Page 9: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Built in form serializer

• Browser detector

• noconflict()

• each() – my favorite

• grep()

• unique() – remove duplicates

What else?

April 12, 2023 9

Page 10: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Add event to any link on page(function($) {

$("a").click(function() {

alert("Hello world!");

});

})(jQuery);

• To add to the first link found only:$(“a:first”).click(function() {

What does jQuery code look like?

April 12, 2023 10

Page 11: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• How about chaining?

$(".testing").click(function() {

$(this).css(“color”, “red”).html(“my text”) .append(“Hello”).remove();

});

• Unlimited potential

What does jQuery code look like?

April 12, 2023 11

Page 12: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• How about some Ajax?

$.ajax({type: "POST",url: "/mail/mcount/“,dataType: “html",success: function(msg){

$(“#target”).html(msg);}

});

What does jQuery code look like?

April 12, 2023 12

Page 13: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Currently over 180 plug-ins

• Range from effects to Flash detectors to DOM manipulators, to form validators

• Can be combined into one file and minified

• New ones popping up every week

Are there good plug-ins?

April 12, 2023 13

Page 14: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• Moved many plug-ins into one core supported by core contributors

• Includes (currently):

jQuery UI

April 12, 2023 14

• Drag / Drop• Sortable• Selectables• Resizables• Accordian• Magnifier

• Calendar• Slider• Table• Tabs• Shadow

Page 15: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• http://www.digg.com

• http://ui.jquery.com/

How about an example or two?

April 12, 2023 15

Page 16: Intro to jQuery - Tulsa Ruby Group

Intro to jQuery

• www.jquery.com

• www.jquery.com/api/

• http://groups.google.com/groups/en-jquery/

• http://ui.jquery.com/

Resources

April 12, 2023 16

Page 17: Intro to jQuery - Tulsa Ruby Group

Questions?

[email protected]

Intro to jQuery