Jquery Mobile: A Touch-Optimized Web Framework For Smartphone & Tablets
Jquery Mobile: A Touch-Optimized Web Framework For Smartphone & Tablets
Jquery Mobile: A Touch-Optimized Web Framework For Smartphone & Tablets
By Ankit Garg
ankit.rgarg@patni.com
Mobile Web is Massive
Goals and Philosophy
This is Web, People want it to work Everywhere
Unified System
Universal Access
Easy Development
One CodeBase All Platforms
Works EveryWhere.
Experience varies based on capabilities.
Built Using
Progressive Enhancement
Current Status
Alpha 4.1 is realeased but is still buggy
Getting Started with jQuery Mobile
Download jQuery Mobile
<html>
<head>
</script>
</head>
Use the CDN
1. <link rel="stylesheet"
href="http://code.jquery.com/mobile/1.0a4.1
/jquery.mobile-1.0a4.1.min.css" />
2. <script
src="http://code.jquery.com/jquery-
1.5.2.min.js"></script>
3. <script
src="http://code.jquery.com/mobile/1.0a4.1/
jquery.mobile-1.0a4.1.min.js"></script>
jQuery Mobile Page Structure
Page
The jQuery Mobile page structure
<body>
<div data-role="page">
<!-- jQuery Mobile page content goes here -->
</div><!-- /page -->
</body>
Multi Page Document
<body>
<div data-role="page" id="home">
</div><!-- /home page -->
<div data-role="page" id="products">
</div><!-- /products page -->
<div data-role="page" id="services">
</div><!-- /home page -->
<div data-role="page" id="about">
</div><!-- /home page -->
<div data-role="page" id="contact">
</div><!-- /home page -->
</body>
Multi Page Demo
Basic List
<div data-role="content">
<p>Hello world</p>
<ul>
<li>Products</li>
<li>Services</li>
<li>About us</li>
<li>Contact</li>
</ul>
</div><!-- /content -->
Basic List Output
Add data-role and see the magic
<div data-role="content">
<p>Hello world</p>
<ul data-role="listview" data-
inset="true">
<li>Products</li>
<li>Services</li>
<li>About us</li>
<li>Contact</li>
</ul>
</div><!-- /content -->
List on Device
Basic List Demo
Linking each Item
<div data-role="content">
<p>Hello world</p>
<ul data-role="listview" data-inset="true">
<li><a
href="products.html">Products</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="about.html">About us</a></li>
<li><a
href="contact.html">Contact</a></li>
</ul>
</div><!-- /content -->
Linking each item
Linking of Pages
<p>Hello world</p>
</ul>
– Slideup
– Slidedown
– Pop
– Fade
– Flip
Transition Demo
Dialogs
• <a href="products.html" data-rel="dialog"
data-transition="pop">Open dialog</a>
Framework adds styles to add rounded corners, margins around the page and a
dark background to make the "dialog" appear to be suspended above the page.
Dialog
Dialog Demo
ToolBars
Two standard types of toolbars
– The Header bar serves as the page title, is usually the first
element inside each mobile page, and typically contains a
<div data-role="header">
<a href="index.html" data-icon="delete">Cancel</a>
<h1>Edit Contact</h1>
<a href="index.html" data-icon="check" data-
theme="b">Save</a>
</div>
Auto Back Button
<div data-role="header">
<h1>Page Title</h1>
</div>
Custom Back Button
<div data-role="header">
<h1>Page Title</h1>
</div>
Footer
<div data-role="footer">
<a href="index.html" data-role="button" data-icon="delete">Remove</a>
<a href="index.html" data-role="button" data-icon="plus">Add</a>
<a href="index.html" data-role="button" data-icon="arrow-u">Up</a>
<a href="index.html" data-role="button" data-icon="arrow-d">Down</a>
</div>
Navbar
<div data-role=“footer”>
<div data-role="navbar">
<ul>
<li><a href="a.html" class="ui-btn-active">One</a></li>
<li><a href="b.html">Two</a></li>
</ul>
</div><!-- /navbar -->
</div>
Navbar with icons
data-position=”fixed”
data-fullscreen=”true”
ListView
Unordered List Ordered List
Nested List or Drillable pages
Split Button List
<li>
<img src="images/gf.png" alt="France" class="ui-li-icon">
<a href="france/">France</a>
<span class="ui-li-count">4</span>
</li>
List Dividers
<li data-role="list-divider">A</li>
Filter Bar
<ul data-filter="true">
Inset Style
<ul data-inset="true">
Advanced List Demo
Buttons
<div data-role="controlgroup">
<a href="index.html" data-role="button">Yes</a>
<a href="index.html" data-role="button">No</a>
<a href="index.html" data-role="button">Maybe</a>
</div>
Horizontal Groups
<div data-inline="true">
<a href="index.html" data-role="button" data-
inline=”true”>Cancel</a>
<a href="index.html" data-role="button" data-theme="b" data-
inline=”true”>Save</a>
</div>
Button Demo
Forms
• Start with a basic form element.
• Associate Labels with Ids
<label for="find">Search:</label>
<input type="search" id="find" value="" />
Slider
<div data-role="fieldcontain">
<label for="slider">Input slider:</label>
<input type="range" name="slider"
id="slider" value="50" min="0" max="100" />
</div>
Flip Switch Slider
<label for="switch">Flip switch:</label>
<select name="switch" id="switch" data-
role="slider">
<option value="off">Off</option>
<option value="on">On</option>
</select>
Radio Button
• <fieldset data-role="controlgroup">
• <legend>Choose a pet:</legend>
• <label for="r1">Cat</label>
• <label for="r2">Dog</label>
• <label for="r3">Hampster</label>
• <label for="r4">Lizard</label>
• </fieldset>
RadioButton