SlideShare a Scribd company logo
1 of 73
Download to read offline
Web2.0 with jQuery

faster, easier and a lot more fun
Hello!




Lau Bech Lauritzen



                              ★2
Todays menu
      Web
  Browser
Javascript
   jQuery
   Plugins
      Tips



                ★3
Web 1.0
• Monologue
• A lot of page changes
• Short time on each page




                            ★4
Hi, I’m
JavaScript!       AND I’m
              XMLHttpRequest




                               ★5
Web 2.0
•   Dialogue – user-generated content
•   Increased interaction
•   User experience
•   Webapplications




                                        ★6
★7
Client-Side Technology


  Communication
      Ajax
  Interaction
    Events
Animation
  Bling




                             ★8
Ajax




       ★9
Asyncronous javascript and xML
       XMLHttpRequest




                                 ★ 10
/ajax/form




               Server
XML/JSON




             ★ 11
Javascript



             ★ 12
The History of Javascript
•   1995 JavaScript in Netscape
•   1996 JScript in Internet Explorer
•   1997 ECMAScript standard
•   1999-2005 – Ajax roll-out
•   2006 XHR standard
•   95% Javascript enabled
•   Huge platform

                                        ★ 13
Javascript
•   Weird name
•   Complete language
•   Object orientered
•   First-class functions
•   Dynamically typed
•   General purpose



                                 ★ 14
CSS                  HTML

       Document Object Model

Javascript
                           layout



                                    ★ 15
DOM


                                             CSS
                     <!DOCTYPE HTML            JS
                     <html>                      JS

DOM != source code    <head>
                       <title>Index</head>
                      </head>
                      <body>                          Webserver



                                                             ★ 16
ARGH!


// Mozilla, Opera and webkit nightlies currently support this event
if ( document.addEventListener ) {
  // Use the handy event callback
  document.addEventListener( "DOMContentLoaded", function(){
    document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
    jQuery.ready();
  }, false );

// If IE event model is used
} else if ( document.attachEvent ) {
  // ensure firing before onload,
  // maybe late but safe also for iframes
  document.attachEvent("onreadystatechange", function(){
    if ( document.readyState === "complete" ) {
      document.detachEvent( "onreadystatechange", arguments.callee );
      jQuery.ready();
    }
  });

    // If IE and not an iframe
    // continually check to see if the document is ready
    if ( document.documentElement.doScroll && window == window.top ) (function(){
      if ( jQuery.isReady ) return;

      try {
        // If IE is used, use the trick by Diego Perini
        // http://javascript.nwbox.com/IEContentLoaded/
        document.documentElement.doScroll("left");
      } catch( error ) {
        setTimeout( arguments.callee, 0 );
        return;
      }
    })();
}


                                                                                        ★ 17
$(document).ready(…);




                        ★ 18
Annoying API


var newDiv = document.createElement("div");
newDiv.innerHTML = "<h1>Hej fra Danmark!</h1>";
var orgDiv = document.getElementById("orgDiv");
document.body.insertBefore(newDiv, orgDiv);




                                                  ★ 19
$(“#orgDiv”).before(“<h1>Hej!</h1>”);




                                        ★ 20
Spaghetti
<script>
  function setLogout(obj) { ... }
</script>
<a
href="javascript:toggle('textde');document.getElementById(
'textes').style.display =
'none';document.getElementById('textfr').style.display =
'none';document.getElementById('textgb').style.display =
'none';void(0);"><img src="/img/debig.png" style="margin:
5px;"></a>
<a href="javascript:void(0);"
onclick="toggle('loginMenu');setLogout(this);void(0);"
onfocus="blur();">Log ind</a>



                                                         ★ 21
<a class=“language” href=“/de/">
  <img src=“/img/debig.png“/>
</a>
<a class=“login” href=“/login/“>Log ind</a>
<script src=“common.js”/>




                                        ★ 22
The Language




               ★ 23
Javascript toolkits




                      ★ 24
★ 25
★ 26
★ 27
jQuery
•   Started January 2006
•   Simplify and speed up webdevelopment
•   DOM query language with CSS-notation
•   Minimal core – extendable through plugins
•   Unobtrusive
•   Test suite 50 browsers, 11 platforms
•   Large community – lots of plugins

                                                ★ 28
Dig?




       ★ 29
★ 30
Compatibility



IE 6.0+, FF 2+, Safari 3.0+,
Opera 9.0+, Chrome




                               ★ 31
★ 32
jQuery is designed to change
the way you write Javascript




                               ★ 33
jQuery basics
•   Include a single Javascript file
•   jQuery uses 19 KB
•   Only adds ”jQuery” to the global scope
•   Everything is accessed through the jQuery object
•   $ is a shortcut




                                                ★ 34
The jQuery Way


$( Find Things )
                   . Do Stuff ();




                                    ★ 35
The jQuery Way
         selector

  $( Find Things )
jQuery               . Do Stuff ();
                        method




                                      ★ 36
$(”div”).hide();
$(”input”).remove();
$(”form”).submit();
$(”p”).addClass(”highlight”);
$(”span”).fadeIn(”fast”);




                                ★ 37
The jQuery Object
• List of DOM elements
• Array-like
• Methods
  – Implicit og explicit iteration
  – Some act only on the first element




                                         ★ 38
Selectors
$(”#menu”)
$(”.redButton”)
$(”p > a”)
$(”tr:even”)
$(”h1, h2, h3”)
$(”input[name=email]”)
$(”li:visible”)


                         http://docs.query.com/Selectors
                                                     ★ 39
Chaining


$(”a”).addClass(”active”)
      .css(”color”, ”yellow”)
      .show();




                                ★ 40
jQuery API
• Concise, natural, consistant
• Logical, often guessable
• Easy to read, understand and remember




                                          ★ 41
jQuery’s Focus
•   DOM manipulation
•   Events
•   Ajax
•   Animation




                               ★ 42
DOM
•   .next() .prev()
•   .find() .children()
•   .parent() .parents()
•   .filter() siblings()




                             ★ 43
Manipulation
•   .text() .html()
•   .attr() .removeAttr() .val()
•   .remove() .empty()
•   .css() .clone()
•   .wrap() .wrapInner() .wrapAll()




                                      ★ 44
CSS
•   .css(key, value)
•   .css({key: value, key: value, ...})
•   .addClass() .removeClass()
•   .toggleClass()




                                          ★ 45
DOM Construction
•   .append() .prepend()
•   .before() .after()
•   .insertBefore() .insertAfter()
•   $(”<div>New element</div>”)

    var jDom = $(response);
    $(”.content”, jDom).appendTo(”body”);



                                            ★ 46
jQuery Overload
•   $(selector)
•   $(HTML)
•   $(DOM element)
•   $(function)




                               ★ 47
★ 48
DEMO




       ★ 49
Events
•   .click(function) .click()
•   .toggle(function1, function2, ...) .toggle()
•   .bind(name, function)
•   .one(name, function)
•   .trigger(name)
•   .live(name, function), .die(name)
•   .hover(function, function), etc.

                                                   ★ 50
Event Handler Callbacks
• this always points to the DOM element
• The event is passed as the first argument

   $(”a”).click(function(event) {
     alert(event.type);
     alert(this.href);
     alert($(this).attr(”href”));
   });



                                              ★ 51
Ajax
•   .load(url)
•   .load(url + ” ” + selector)
•   $.get()
•   $.post()
•   $.getJSON()
•   $.getScript()
•   $.ajax()

                                  ★ 52
Animations
•   .show() .hide() .toggle()
•   .fadeIn() .fadeOut() .fadeTo()
•   .slideUp() .slideDown() .slideToggle()
•   .animate() .stop()




                                             ★ 53
Misc
• .data(key, value)
• Utility functions
  – $.browser $.each() $.extend() $.merge() $.grep()




                                                  ★ 54
DEMO




       ★ 55
Plugin System
• Goal: keep a small jQuery core
• Plugin system provides extensibility
• >4.500 plugins
  – Ajax, animations, forms, menus, widgets
• Easy to build
• Lots of small plugins



                                              ★ 56
<script src=”jquery.js”/>
<script src=”jquery.cookie.js”/>
<script src=”jquery.lightbox.js”/>




                                     ★ 57
Writing a Plugin
$.fn.popup = function() {
  this.click(function() {
    var url = $(this).attr("href");
    if (url) {
      $("#dialog").load(url, function() {
        $(this).dialog();
      });
    }
    return false;
  });
  return this;
};




                                            ★ 58
Writing a Plugin
|(function($) {
  $.fn.popup = function() {
     return this.click(function() {
       var url = $(this).attr("href");
       if (url) {
         $("#dialog").load(url, function() {
           $(this).dialog();
         });
       }
       return false;
     });
  };
|})(jQuery);




                                               ★ 59
Writing a Plugin
|(function($) {
  $.fn.popup = function() {
     return this.click(function() {
       var url = $(this).attr("href");
       if (url) {
         $("#dialog").load(url, function() {
           $(this).dialog();
         });
       }
       return false;
     });
  };
|})(jQuery);

$(”.popup”).popup();


                                               ★ 60
Writing a Plugin
(function($) {
  $.fn.popup = function(container, options) {
|   var settings= $.extend({
|     attribute: ”href”
|   }, options);
    return this.click(function() {
      var url = $(this).attr(settings.attribute);
      if (url) {
        $(container).load(url, function() {
          $(this).dialog();
        });
      }
      return false;
    });
  };
})(jQuery);
$(”.popup”).popup(”#dialog”, {attribute: ”name”});



                                                     ★ 61
Flot




       ★ 62
Integration



$.plot(”#plot”, data);




               http://code.google.com/p/flot/
                                           ★ 63
DEMO




       ★ 64
jQuery UI




            ★ 65
★ 66
jQuery Mobile
•   Cross-platform
•   Markup-based
•   Progressive enhancement
•   Events
•   Unified UI




                               ★ 67
DEMO




       ★ 68
Tips
•   Keep Javascript in files
•   Google CDN
•   Profile code
•   Use plugins!
•   Minify code




                                ★ 69
Performance


$(”#id”)     $(”form[name*=email]”)



 var form = $(”form[name*=email]”);
 $(”input[name=address]”, form).val();
 form.submit();




                                         ★ 70
Development Environment
• Firefox
• Firebug
   –   Javascript consol
   –   HTTP requests
   –   Profiler
   –   Plugins – cookies, speed test, etc.
• Web Developer
• Fiddler – Ajax debugging
• Good editor
   – Syntax highlighting
   – Indention
   – TextMate, Notepad++, Emacs


                                             ★ 71
The Horison
•   Javascript interpreters
•   Desktop Javascript
•   HTML5
•   Mobile




                                ★ 72
Happy coding!
    lau@iola.dk

More Related Content

What's hot

Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)iloveigloo
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)jeresig
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)jeresig
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)jeresig
 
State of jQuery and Drupal
State of jQuery and DrupalState of jQuery and Drupal
State of jQuery and Drupaljeresig
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)jeresig
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)jeresig
 
jQuery (MeshU)
jQuery (MeshU)jQuery (MeshU)
jQuery (MeshU)jeresig
 
An in-depth look at jQuery
An in-depth look at jQueryAn in-depth look at jQuery
An in-depth look at jQueryPaul Bakaus
 
OOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonOOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonJohn Hann
 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UIPaul Bakaus
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessorAlessandro Nadalin
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)jeresig
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Kris Wallsmith
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone InteractivityEric Steele
 
How dojo works
How dojo worksHow dojo works
How dojo worksAmit Tyagi
 

What's hot (20)

Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)Client-side MVC with Backbone.js (reloaded)
Client-side MVC with Backbone.js (reloaded)
 
JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)JavaScript Library Overview (Ajax Exp West 2007)
JavaScript Library Overview (Ajax Exp West 2007)
 
J query module1
J query module1J query module1
J query module1
 
Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)Introduction to jQuery (Ajax Exp 2007)
Introduction to jQuery (Ajax Exp 2007)
 
jQuery (BostonPHP)
jQuery (BostonPHP)jQuery (BostonPHP)
jQuery (BostonPHP)
 
State of jQuery and Drupal
State of jQuery and DrupalState of jQuery and Drupal
State of jQuery and Drupal
 
JavaScript Libraries (@Media)
JavaScript Libraries (@Media)JavaScript Libraries (@Media)
JavaScript Libraries (@Media)
 
Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)Advanced jQuery (Ajax Exp 2007)
Advanced jQuery (Ajax Exp 2007)
 
jQuery (MeshU)
jQuery (MeshU)jQuery (MeshU)
jQuery (MeshU)
 
An in-depth look at jQuery
An in-depth look at jQueryAn in-depth look at jQuery
An in-depth look at jQuery
 
OOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon BostonOOCSS for JavaScript Pirates jQcon Boston
OOCSS for JavaScript Pirates jQcon Boston
 
An in-depth look at jQuery UI
An in-depth look at jQuery UIAn in-depth look at jQuery UI
An in-depth look at jQuery UI
 
The state of your own hypertext preprocessor
The state of your own hypertext preprocessorThe state of your own hypertext preprocessor
The state of your own hypertext preprocessor
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
The jQuery Library
The  jQuery LibraryThe  jQuery Library
The jQuery Library
 
Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3Introducing Assetic: Asset Management for PHP 5.3
Introducing Assetic: Asset Management for PHP 5.3
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
From render() to DOM
From render() to DOMFrom render() to DOM
From render() to DOM
 
How dojo works
How dojo worksHow dojo works
How dojo works
 

Viewers also liked

Artelements
ArtelementsArtelements
ArtelementsLES
 
Haskell Foundations
Haskell FoundationsHaskell Foundations
Haskell Foundationsguestf8c45d
 
Sky math challenge 7H
Sky math challenge 7HSky math challenge 7H
Sky math challenge 7Hecooperms
 
Katrina math 7H
Katrina math 7HKatrina math 7H
Katrina math 7Hecooperms
 
Hyuk chan polyhedra
Hyuk chan polyhedraHyuk chan polyhedra
Hyuk chan polyhedraecooperms
 
مهارات التخطيط 2
مهارات التخطيط 2مهارات التخطيط 2
مهارات التخطيط 2Mohammed Ali
 
Keller (Bellevue/NYU) - Health and Human Rights
Keller (Bellevue/NYU) - Health and Human RightsKeller (Bellevue/NYU) - Health and Human Rights
Keller (Bellevue/NYU) - Health and Human Rightsguestc7da32
 
Binary number
Binary numberBinary number
Binary numberecooperms
 
Bankole (Guttmacher) - Unsafe Abortion
Bankole (Guttmacher) - Unsafe AbortionBankole (Guttmacher) - Unsafe Abortion
Bankole (Guttmacher) - Unsafe Abortionguestc7da32
 
مهارات التخطيط 1
مهارات التخطيط 1مهارات التخطيط 1
مهارات التخطيط 1Mohammed Ali
 
Adam aryabhatta
Adam aryabhattaAdam aryabhatta
Adam aryabhattaecooperms
 
Chae un simultaneous equation
Chae un simultaneous equationChae un simultaneous equation
Chae un simultaneous equationecooperms
 
Hub and Spoke
Hub and SpokeHub and Spoke
Hub and SpokeWei Min
 

Viewers also liked (17)

Artelements
ArtelementsArtelements
Artelements
 
mpfi20080910
mpfi20080910mpfi20080910
mpfi20080910
 
Haskell Foundations
Haskell FoundationsHaskell Foundations
Haskell Foundations
 
Web2.0 with jQuery
Web2.0 with jQueryWeb2.0 with jQuery
Web2.0 with jQuery
 
Conjuntivitis
ConjuntivitisConjuntivitis
Conjuntivitis
 
Phones magazine
Phones magazinePhones magazine
Phones magazine
 
Sky math challenge 7H
Sky math challenge 7HSky math challenge 7H
Sky math challenge 7H
 
Katrina math 7H
Katrina math 7HKatrina math 7H
Katrina math 7H
 
Hyuk chan polyhedra
Hyuk chan polyhedraHyuk chan polyhedra
Hyuk chan polyhedra
 
مهارات التخطيط 2
مهارات التخطيط 2مهارات التخطيط 2
مهارات التخطيط 2
 
Keller (Bellevue/NYU) - Health and Human Rights
Keller (Bellevue/NYU) - Health and Human RightsKeller (Bellevue/NYU) - Health and Human Rights
Keller (Bellevue/NYU) - Health and Human Rights
 
Binary number
Binary numberBinary number
Binary number
 
Bankole (Guttmacher) - Unsafe Abortion
Bankole (Guttmacher) - Unsafe AbortionBankole (Guttmacher) - Unsafe Abortion
Bankole (Guttmacher) - Unsafe Abortion
 
مهارات التخطيط 1
مهارات التخطيط 1مهارات التخطيط 1
مهارات التخطيط 1
 
Adam aryabhatta
Adam aryabhattaAdam aryabhatta
Adam aryabhatta
 
Chae un simultaneous equation
Chae un simultaneous equationChae un simultaneous equation
Chae un simultaneous equation
 
Hub and Spoke
Hub and SpokeHub and Spoke
Hub and Spoke
 

Similar to Web2.0 with jQuery in English

User Interface Development with jQuery
User Interface Development with jQueryUser Interface Development with jQuery
User Interface Development with jQuerycolinbdclark
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAmir Barylko
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jqueryKostas Mavridis
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
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
 
Tips for writing Javascript for Drupal
Tips for writing Javascript for DrupalTips for writing Javascript for Drupal
Tips for writing Javascript for DrupalSergey Semashko
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile IntroGonzalo Parra
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Thinqloud
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)jeresig
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)David Giard
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureNicolas Corrarello
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Railsshen liu
 

Similar to Web2.0 with jQuery in English (20)

bcgr3-jquery
bcgr3-jquerybcgr3-jquery
bcgr3-jquery
 
Jquery
JqueryJquery
Jquery
 
User Interface Development with jQuery
User Interface Development with jQueryUser Interface Development with jQuery
User Interface Development with jQuery
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
Awesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescriptAwesome html with ujs, jQuery and coffeescript
Awesome html with ujs, jQuery and coffeescript
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
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
 
Tips for writing Javascript for Drupal
Tips for writing Javascript for DrupalTips for writing Javascript for Drupal
Tips for writing Javascript for Drupal
 
Mume JQueryMobile Intro
Mume JQueryMobile IntroMume JQueryMobile Intro
Mume JQueryMobile Intro
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
 
Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)Nodejs - A quick tour (v4)
Nodejs - A quick tour (v4)
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)Introduction to jQuery (Ajax Exp 2006)
Introduction to jQuery (Ajax Exp 2006)
 
JS Essence
JS EssenceJS Essence
JS Essence
 
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)How I Learned to Stop Worrying and Love jQuery (Jan 2013)
How I Learned to Stop Worrying and Love jQuery (Jan 2013)
 
JQuery UI
JQuery UIJQuery UI
JQuery UI
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
HashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin InfrastructureHashiCorp Vault Plugin Infrastructure
HashiCorp Vault Plugin Infrastructure
 
Jquery In Rails
Jquery In RailsJquery In Rails
Jquery In Rails
 

Recently uploaded

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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 2024The Digital Insurer
 
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, Adobeapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
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 DiscoveryTrustArc
 
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...DianaGray10
 

Recently uploaded (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
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
 
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...
 

Web2.0 with jQuery in English

  • 1. Web2.0 with jQuery faster, easier and a lot more fun
  • 3. Todays menu Web Browser Javascript jQuery Plugins Tips ★3
  • 4. Web 1.0 • Monologue • A lot of page changes • Short time on each page ★4
  • 5. Hi, I’m JavaScript! AND I’m XMLHttpRequest ★5
  • 6. Web 2.0 • Dialogue – user-generated content • Increased interaction • User experience • Webapplications ★6
  • 8. Client-Side Technology Communication Ajax Interaction Events Animation Bling ★8
  • 9. Ajax ★9
  • 10. Asyncronous javascript and xML XMLHttpRequest ★ 10
  • 11. /ajax/form Server XML/JSON ★ 11
  • 12. Javascript ★ 12
  • 13. The History of Javascript • 1995 JavaScript in Netscape • 1996 JScript in Internet Explorer • 1997 ECMAScript standard • 1999-2005 – Ajax roll-out • 2006 XHR standard • 95% Javascript enabled • Huge platform ★ 13
  • 14. Javascript • Weird name • Complete language • Object orientered • First-class functions • Dynamically typed • General purpose ★ 14
  • 15. CSS HTML Document Object Model Javascript layout ★ 15
  • 16. DOM CSS <!DOCTYPE HTML JS <html> JS DOM != source code <head> <title>Index</head> </head> <body> Webserver ★ 16
  • 17. ARGH! // Mozilla, Opera and webkit nightlies currently support this event if ( document.addEventListener ) { // Use the handy event callback document.addEventListener( "DOMContentLoaded", function(){ document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); jQuery.ready(); }, false ); // If IE event model is used } else if ( document.attachEvent ) { // ensure firing before onload, // maybe late but safe also for iframes document.attachEvent("onreadystatechange", function(){ if ( document.readyState === "complete" ) { document.detachEvent( "onreadystatechange", arguments.callee ); jQuery.ready(); } }); // If IE and not an iframe // continually check to see if the document is ready if ( document.documentElement.doScroll && window == window.top ) (function(){ if ( jQuery.isReady ) return; try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ document.documentElement.doScroll("left"); } catch( error ) { setTimeout( arguments.callee, 0 ); return; } })(); } ★ 17
  • 19. Annoying API var newDiv = document.createElement("div"); newDiv.innerHTML = "<h1>Hej fra Danmark!</h1>"; var orgDiv = document.getElementById("orgDiv"); document.body.insertBefore(newDiv, orgDiv); ★ 19
  • 21. Spaghetti <script> function setLogout(obj) { ... } </script> <a href="javascript:toggle('textde');document.getElementById( 'textes').style.display = 'none';document.getElementById('textfr').style.display = 'none';document.getElementById('textgb').style.display = 'none';void(0);"><img src="/img/debig.png" style="margin: 5px;"></a> <a href="javascript:void(0);" onclick="toggle('loginMenu');setLogout(this);void(0);" onfocus="blur();">Log ind</a> ★ 21
  • 22. <a class=“language” href=“/de/"> <img src=“/img/debig.png“/> </a> <a class=“login” href=“/login/“>Log ind</a> <script src=“common.js”/> ★ 22
  • 23. The Language ★ 23
  • 28. jQuery • Started January 2006 • Simplify and speed up webdevelopment • DOM query language with CSS-notation • Minimal core – extendable through plugins • Unobtrusive • Test suite 50 browsers, 11 platforms • Large community – lots of plugins ★ 28
  • 29. Dig? ★ 29
  • 31. Compatibility IE 6.0+, FF 2+, Safari 3.0+, Opera 9.0+, Chrome ★ 31
  • 33. jQuery is designed to change the way you write Javascript ★ 33
  • 34. jQuery basics • Include a single Javascript file • jQuery uses 19 KB • Only adds ”jQuery” to the global scope • Everything is accessed through the jQuery object • $ is a shortcut ★ 34
  • 35. The jQuery Way $( Find Things ) . Do Stuff (); ★ 35
  • 36. The jQuery Way selector $( Find Things ) jQuery . Do Stuff (); method ★ 36
  • 38. The jQuery Object • List of DOM elements • Array-like • Methods – Implicit og explicit iteration – Some act only on the first element ★ 38
  • 39. Selectors $(”#menu”) $(”.redButton”) $(”p > a”) $(”tr:even”) $(”h1, h2, h3”) $(”input[name=email]”) $(”li:visible”) http://docs.query.com/Selectors ★ 39
  • 40. Chaining $(”a”).addClass(”active”) .css(”color”, ”yellow”) .show(); ★ 40
  • 41. jQuery API • Concise, natural, consistant • Logical, often guessable • Easy to read, understand and remember ★ 41
  • 42. jQuery’s Focus • DOM manipulation • Events • Ajax • Animation ★ 42
  • 43. DOM • .next() .prev() • .find() .children() • .parent() .parents() • .filter() siblings() ★ 43
  • 44. Manipulation • .text() .html() • .attr() .removeAttr() .val() • .remove() .empty() • .css() .clone() • .wrap() .wrapInner() .wrapAll() ★ 44
  • 45. CSS • .css(key, value) • .css({key: value, key: value, ...}) • .addClass() .removeClass() • .toggleClass() ★ 45
  • 46. DOM Construction • .append() .prepend() • .before() .after() • .insertBefore() .insertAfter() • $(”<div>New element</div>”) var jDom = $(response); $(”.content”, jDom).appendTo(”body”); ★ 46
  • 47. jQuery Overload • $(selector) • $(HTML) • $(DOM element) • $(function) ★ 47
  • 49. DEMO ★ 49
  • 50. Events • .click(function) .click() • .toggle(function1, function2, ...) .toggle() • .bind(name, function) • .one(name, function) • .trigger(name) • .live(name, function), .die(name) • .hover(function, function), etc. ★ 50
  • 51. Event Handler Callbacks • this always points to the DOM element • The event is passed as the first argument $(”a”).click(function(event) { alert(event.type); alert(this.href); alert($(this).attr(”href”)); }); ★ 51
  • 52. Ajax • .load(url) • .load(url + ” ” + selector) • $.get() • $.post() • $.getJSON() • $.getScript() • $.ajax() ★ 52
  • 53. Animations • .show() .hide() .toggle() • .fadeIn() .fadeOut() .fadeTo() • .slideUp() .slideDown() .slideToggle() • .animate() .stop() ★ 53
  • 54. Misc • .data(key, value) • Utility functions – $.browser $.each() $.extend() $.merge() $.grep() ★ 54
  • 55. DEMO ★ 55
  • 56. Plugin System • Goal: keep a small jQuery core • Plugin system provides extensibility • >4.500 plugins – Ajax, animations, forms, menus, widgets • Easy to build • Lots of small plugins ★ 56
  • 58. Writing a Plugin $.fn.popup = function() { this.click(function() { var url = $(this).attr("href"); if (url) { $("#dialog").load(url, function() { $(this).dialog(); }); } return false; }); return this; }; ★ 58
  • 59. Writing a Plugin |(function($) { $.fn.popup = function() { return this.click(function() { var url = $(this).attr("href"); if (url) { $("#dialog").load(url, function() { $(this).dialog(); }); } return false; }); }; |})(jQuery); ★ 59
  • 60. Writing a Plugin |(function($) { $.fn.popup = function() { return this.click(function() { var url = $(this).attr("href"); if (url) { $("#dialog").load(url, function() { $(this).dialog(); }); } return false; }); }; |})(jQuery); $(”.popup”).popup(); ★ 60
  • 61. Writing a Plugin (function($) { $.fn.popup = function(container, options) { | var settings= $.extend({ | attribute: ”href” | }, options); return this.click(function() { var url = $(this).attr(settings.attribute); if (url) { $(container).load(url, function() { $(this).dialog(); }); } return false; }); }; })(jQuery); $(”.popup”).popup(”#dialog”, {attribute: ”name”}); ★ 61
  • 62. Flot ★ 62
  • 63. Integration $.plot(”#plot”, data); http://code.google.com/p/flot/ ★ 63
  • 64. DEMO ★ 64
  • 65. jQuery UI ★ 65
  • 67. jQuery Mobile • Cross-platform • Markup-based • Progressive enhancement • Events • Unified UI ★ 67
  • 68. DEMO ★ 68
  • 69. Tips • Keep Javascript in files • Google CDN • Profile code • Use plugins! • Minify code ★ 69
  • 70. Performance $(”#id”) $(”form[name*=email]”) var form = $(”form[name*=email]”); $(”input[name=address]”, form).val(); form.submit(); ★ 70
  • 71. Development Environment • Firefox • Firebug – Javascript consol – HTTP requests – Profiler – Plugins – cookies, speed test, etc. • Web Developer • Fiddler – Ajax debugging • Good editor – Syntax highlighting – Indention – TextMate, Notepad++, Emacs ★ 71
  • 72. The Horison • Javascript interpreters • Desktop Javascript • HTML5 • Mobile ★ 72
  • 73. Happy coding! lau@iola.dk

Editor's Notes

  1. Lau: uni, 27 år, nørd – Gaja 1982, nørdet, nørdet på en anden måde IOLA: 3 år, ungt softwarefirma, webapplikationer jQuery + Python!
  2. Webudviklere? Javascript? DOM? AJAX? jQuery?
  3. Pardigmeskifte – opføre sig mere som applikationer, webplatformen smooth, ingen installation Brugeradfæren ændrede sig, ikke længere sidde passivt, facebook, forums, open source software Få sideskift, længe på hver side Brugeroplevelsen – fra information -&gt; en oplevelse, meninger og holdninger Højere kompleksitet – krav til udvilkingsværktøj
  4. Nem interaction, intuitivt, umiddelbart, nemt at interagere, web2.0 deisgn = simplicitet, ellers går brugerne et andet sted hed
  5. Document Object Model (DOM) Webplatformen Bruges mere og mere til forretnings applikationer
  6. 1995: kendt som DHTML, ingen ajax XHR: 1999 MS, 2000-2002 Mozilla, standard 2006
  7. I/O, adobe air Navn: LiveScript, standardiseret som ECMAScript Anden halvdel af bogen, webdelen, det dårlige ry, browser wars
  8. Dom indeholder: xml struktur, styles, event, data Gennemgå hvorfor js har dårligt ry, danner grundlaget for jquery
  9. Browser implementationer, ingen standard, mange bugs, Mozilla i 1995, Microsoft jScript 1996
  10. Vedligeholdelse, SEO, tilgængelighed
  11. Mange amatører, ingen klasser, dynamiske typer
  12. Mon vores utopiske drømme om at have et kortfattet lækkert nemt-at-huske grænseflade til DOMen kan komme i opfyldelse? 2 hovedfokus for js libs, browser forskelligheder og gør almindelige opgaver nemmere
  13. DOM, events, animationer og Ajax
  14. jQuery er et forholdsvist nyt toolkit
  15. Stor test suite, depricated IE 5.5
  16. Stort community, solidt, mange udvilkere, MIT licens
  17. DOM mulipulation
  18. Et par eksempler
  19. Ren javascript, jquery plugin,
  20. IE8 og Safari har også dev
  21. Fortolkere, ny browser krig, Features: lokal data store, cross-site XHR Desktop: AIR, adobe suite