Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rapidly Develop Mobile Web Applications with jQuery Mobile

Rapidly Develop Mobile Web Applications with jQuery Mobile

This talk focuses on how to effectively use jQuery Mobile to develop robust, cross-platform, mobile web applications. We’ll present an overview of jQuery Mobile, outlining the goals and aims of the project and the pros and cons. You’ll learn the capabilities of jQuery Mobile, walk through the API and review current, sample applications. You’ll also look at an app appendTo has built that demonstrates how easy and efficient it is to build an application with jQuery Mobile.

Mike Hostetler

February 13, 2012
Tweet

More Decks by Mike Hostetler

Other Decks in Programming

Transcript

  1. @mikehostetler BlackBerry DevCon Europe 2012 7% of US Traffic comes

    from SmartPhones and Tablets http://www.comscore.com/Press_Events/Press_Releases/2011/10/ Smartphones_and_Tablets_Drive_Nearly_7_Percent_of_Total_U.S._Digital_Traffic - Sept. 2011 Monday, February 13, 12
  2. @mikehostetler BlackBerry DevCon Europe 2012 The is the web People

    expect it to work everywhere Monday, February 13, 12
  3. @mikehostetler BlackBerry DevCon Europe 2012 Familiar API Style It’s just

    jQuery! $( document ).delegate( ".city", "click", function ( e ) { $( "#dialog" ).one( "pagehide", function () { $.mobile.changePage( 'cities.php' ); }).dialog( "close" ); }); Monday, February 13, 12
  4. @mikehostetler BlackBerry DevCon Europe 2012 Mobile Browser Grades Basic HTML

    C B A Enhanced experience without Ajax Full experience with Ajax-based animated page transitions. Monday, February 13, 12
  5. @mikehostetler BlackBerry DevCon Europe 2012 Your First Page! <!DocType HTML>

    <html> <head> ... <title>My first jQuery Mobile Page!</title> </head> <body> .... </body> </html> Monday, February 13, 12
  6. @mikehostetler BlackBerry DevCon Europe 2012 Add the <script> tags ...

    <!DocType HTML> <html> <head> .... <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.css" /> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script src="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.js"></script> </head> .... </html> Monday, February 13, 12
  7. @mikehostetler BlackBerry DevCon Europe 2012 Add the <script> tags ...

    <!DocType HTML> <html> <head> .... <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.css" /> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script src="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.js"></script> </head> .... </html> Monday, February 13, 12
  8. @mikehostetler BlackBerry DevCon Europe 2012 Add the <script> tags ...

    <!DocType HTML> <html> <head> .... <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.css" /> <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script> <script src="http://code.jquery.com/mobile/1.0rc1/ jquery.mobile-1.0rc1.min.js"></script> </head> .... </html> Monday, February 13, 12
  9. @mikehostetler BlackBerry DevCon Europe 2012 Building your Page <body> <div

    data-role=”page”> <p>Hello World!</p> </div> </body> Monday, February 13, 12
  10. @mikehostetler BlackBerry DevCon Europe 2012 The role of data attributes

    ... <body> <div data-role=”page”> <p>Hello World!</p> </div> </body> Monday, February 13, 12
  11. @mikehostetler BlackBerry DevCon Europe 2012 Full Sample Page <body> <div

    data-role=”page”> <div data-role=”header”> ... </div> <div data-role=”content”> ... </div> <div data-role=”footer”> ... </div> </div> </body> Monday, February 13, 12
  12. @mikehostetler BlackBerry DevCon Europe 2012 Basic List <div data-role=”content”> <h2>Hello

    World!</h2> <ul> <li>jQuery</li> <li>jQuery UI</li> <li>jQuery Mobile</li> <li>QUnit</li> </ul> </div> Monday, February 13, 12
  13. @mikehostetler BlackBerry DevCon Europe 2012 Add the List View Role

    <div data-role=”content”> <h2>Hello World!</h2> <ul data-role="listview"> <li>jQuery</li> <li>jQuery UI</li> <li>jQuery Mobile</li> <li>QUnit</li> </ul> </div> Monday, February 13, 12
  14. @mikehostetler BlackBerry DevCon Europe 2012 Inset Style <div data-role=”content”> <h2>Hello

    World!</h2> <ul data-role="listview" data-inset="true" > <li>jQuery</li> <li>jQuery UI</li> <li>jQuery Mobile</li> <li>QUnit</li> </ul> </div> Monday, February 13, 12
  15. @mikehostetler BlackBerry DevCon Europe 2012 Add Links <ul data-role="listview" data-inset="true">

    <li> <a href=”http://jquery.com”> jQuery </a> </li> ... </ul> Monday, February 13, 12
  16. @mikehostetler BlackBerry DevCon Europe 2012 Ordered Lists <div data-role=”content”> <h2>Hello

    World!</h2> <ol data-role="listview"> <li>jQuery</li> <li>jQuery UI</li> <li>jQuery Mobile</li> <li>QUnit</li> </ol> </div> Monday, February 13, 12
  17. @mikehostetler BlackBerry DevCon Europe 2012 Count Bubbles <ul data-role="listview"> <li><a

    href=”http://jquery.com”> jQuery <span class="ui-li-count">1.6.4</span> </a></li> ... </ul> Monday, February 13, 12
  18. @mikehostetler BlackBerry DevCon Europe 2012 List Dividers <ul data-role="listview"> <li

    data-role="list-divider">Core</li> <li>jQuery</li> <li data-role="list-divider">UI</li> <li>jQuery UI</li> <li>jQuery Mobile</li> <li data-role="list-divider">Testing</li> <li>QUnit</li> </ul> Monday, February 13, 12
  19. @mikehostetler BlackBerry DevCon Europe 2012 Filter Bar <div data-role=”content”> <h2>Hello

    World!</h2> <ul data-role="listview" data-filter="true"> .... </ul> </div> Monday, February 13, 12
  20. @mikehostetler BlackBerry DevCon Europe 2012 Append, then Refresh! $(‘ul#jquery’). .append(

    ‘<li><a href=”http://sizzlejs.com”>Sizzle JS</a></li>’ ).listview( ‘refresh’ ); Monday, February 13, 12
  21. @mikehostetler BlackBerry DevCon Europe 2012 Basic Theming <div data-role=”page” data-theme=”a”>

    <div data-role=”content”> .... </div> </div> Monday, February 13, 12
  22. @mikehostetler BlackBerry DevCon Europe 2012 External Links <ul data-role="listview" data-inset="true"

    data-theme=”e”> <li> <a href=”http://jquery.com”> jQuery </a> </li> ... </ul> Monday, February 13, 12
  23. @mikehostetler BlackBerry DevCon Europe 2012 Internal + Hijax + DOM

    Injection <ul data-role="listview" data-inset="true" data-theme=”e”> <li> <a href=”jquery.html”> jQuery </a> </li> ... </ul> Click! Monday, February 13, 12
  24. @mikehostetler BlackBerry DevCon Europe 2012 Internal + Hijax + DOM

    Injection /index.html /jquery.html Monday, February 13, 12
  25. @mikehostetler BlackBerry DevCon Europe 2012 Internal + Hijax + DOM

    Injection /jquery.html /index.html Monday, February 13, 12
  26. @mikehostetler BlackBerry DevCon Europe 2012 Internal + Hijax + DOM

    Injection /jquery.html /index.html Monday, February 13, 12
  27. @mikehostetler BlackBerry DevCon Europe 2012 External Links <ul data-role="listview" data-inset="true"

    data-theme=”e”> <li> <a href=”http://jquery.com” data-transition="pop"> jQuery a’ Poppin </a> </li> ... </ul> Monday, February 13, 12
  28. @mikehostetler BlackBerry DevCon Europe 2012 Multiple Pages, One DOM <body>

    <div data-role=”page” id=”page1”> <p>Hello World!</p> </div> <div data-role=”page” id=”page2”> <p>Hello World!</p> </div> </body> Monday, February 13, 12
  29. @mikehostetler BlackBerry DevCon Europe 2012 Pre-Fetching <body> <div data-role=”page” id=”page1”>

    <p>Hello World!</p> <a href="prefetchMe.html" data-prefetch> ... </a> </div> <div data-role=”page” id=”page2”> <p>Hello World!</p> </div> </body> Monday, February 13, 12
  30. @mikehostetler BlackBerry DevCon Europe 2012 Basic Form with Labels <div

    data-role="content"> <form action="#" method="get"> <label for="example">Example:</label> <input type="text" name="example" value="" /> </form> </div> Monday, February 13, 12
  31. @mikehostetler BlackBerry DevCon Europe 2012 Containers <div data-role="content"> <form action="#"

    method="get"> <div data-role="fieldcontain"> <label for="example">Example:</label> <input type="text" name="example" value="" /> </div> </form> </div> Monday, February 13, 12
  32. @mikehostetler BlackBerry DevCon Europe 2012 Text Input <div data-role="content"> <form

    action="#" method="get"> <div data-role="fieldcontain"> <label for="example">Example:</label> <input type="text" name="example" value="" /> </div> </form> </div> Monday, February 13, 12
  33. @mikehostetler BlackBerry DevCon Europe 2012 Flip Switch <form action="#" method="get">

    <div data-role="fieldcontain"> <label for="slide">Flip switch:</label> <select name="slide" data-role="slider"> <option value="off">Off</option> <option value="on">On</option> </select> </div> </form> </div> Monday, February 13, 12
  34. @mikehostetler BlackBerry DevCon Europe 2012 Radio Buttons <form action="#" method="get">

    <div data-role="fieldcontain"> <input type="radio" name="choice-1" value="choice-1"> <label for="choice-1">Apples</label> </div> ... </form> </div> Monday, February 13, 12
  35. @mikehostetler BlackBerry DevCon Europe 2012 Checkboxes Too <form action="#" method="get">

    <div data-role="fieldcontain"> <input type="checkbox" name="choice-1" value="choice-1"> <label for="choice-1">Apples</label> </div> ... </form> </div> Monday, February 13, 12
  36. @mikehostetler BlackBerry DevCon Europe 2012 Horizontal Set <form action="#" method="get">

    <div data-role="fieldcontain" data-type=”horizontal”> <input type="checkbox" name="choice-1" value="choice-1"> <label for="choice-1">Apples</label> </div> ... </form> </div> Monday, February 13, 12
  37. @mikehostetler BlackBerry DevCon Europe 2012 Select Lists <form action="#" method="get">

    <div data-role="fieldcontain"> <label for="choice-1"> Choose shipping method:</label> <select name="choice-1"> <option value="std">Standard: 7 day </option> ... </select> </div> </form> </div> Monday, February 13, 12
  38. @mikehostetler BlackBerry DevCon Europe 2012 Select Lists <form action="#" method="get">

    <div data-role="fieldcontain"> <label for="choice-1"> Choose shipping method:</label> <select name="choice-1"> <option value="std">Standard: 7 day </option> ... </select> </div> </form> </div> Monday, February 13, 12
  39. @mikehostetler BlackBerry DevCon Europe 2012 Select Lists - Non-Native <form

    action="#" method="get"> <div data-role="fieldcontain"> <label for="choice-1"> Choose shipping method:</label> <select name="choice-1" data-native-menu="false"> <option value="std">Standard: 7 day </option> ... </select> </div> </form> Monday, February 13, 12
  40. @mikehostetler BlackBerry DevCon Europe 2012 Dialog’s <div data-role="content"> <a href="foo.html"

    data-rel="dialog">Open dialog</a> </div> Monday, February 13, 12
  41. @mikehostetler BlackBerry DevCon Europe 2012 Button’s <div data-role="content"> <a href="#"

    data-role="button"> Link Button</a> <a href="#" data-role="button" data-icon="star">Star Icon!</a> </div> Monday, February 13, 12
  42. @mikehostetler BlackBerry DevCon Europe 2012 Toolbar’s <div data-role="page"> <div data-role="header"

    data-position="inline"> <a href="index.html" data-icon="delete">Cancel</a> <h1>Edit Contact</h1> <a href="index.html" data-icon="check">Save</a> </div> </div> Monday, February 13, 12
  43. @mikehostetler BlackBerry DevCon Europe 2012 Navbar’s <div data-role="page"> .... <div

    data-role="footer"> <div data-role="navbar"> <ul> <li>Summary</li> ... </ul> </div> </div> </div> Monday, February 13, 12
  44. @mikehostetler BlackBerry DevCon Europe 2012 Fixed Positioning <div data-role="page"> <div

    data-role="header" data-position="fixed"> <h1>Fixed toolbars</h1> </div> </div> Monday, February 13, 12
  45. @mikehostetler BlackBerry DevCon Europe 2012 Persistent Footer Bar <div data-role="footer">

    <div data-role="navbar" class="ui-state-persist"> <p><a href=”#”>Friends</a></p> </div> </div> Monday, February 13, 12
  46. @mikehostetler BlackBerry DevCon Europe 2012 New Events ‣tap, taphold ‣swipe,

    swipeleft, swiperight ‣scrollstart, scrollstop ‣orientationchange ‣Page Load: pageloadbefore, pageload, pageloadfailed ‣Page Change: pagechangebefore, pagechange, pagechangefailed ‣Many More! Monday, February 13, 12
  47. @mikehostetler BlackBerry DevCon Europe 2012 Virtual Mouse Events ‣vmouseover ‣vmousedown

    ‣vmousemove ‣vmouseup ‣vmouseclick - WARNING! ‣vmousecancel Monday, February 13, 12
  48. @mikehostetler BlackBerry DevCon Europe 2012 Changing Pages // Mimic’s a

    ‘tap’ or ‘click’ $.mobile.changePage( ‘about/us.html’ OR $(‘#about’), { /* options */ } ); // Fetches external URL, inserts it into the DOM $.mobile.loadPage( ‘about/us.html’, { /* options */ } ); Monday, February 13, 12
  49. @mikehostetler BlackBerry DevCon Europe 2012 Those data- attributes ... Don’t

    use: $.data Use: jqmData() and jqmRemoveData() Monday, February 13, 12
  50. @mikehostetler BlackBerry DevCon Europe 2012 URL’s & Paths $.mobile.path URL:

    http://jblas:[email protected]:8080/mail/inbox? msg=1234&type=unread#msg-content obj = { domain: ‘http://jblas:[email protected]:8080’, host: ‘mycompany.com:8080’, pathname: ’/mail/inbox’, directory: ‘/mail/’ } Monday, February 13, 12