Introduction to jQueryMobile
Following is an extract from jQueryMobile site -
jQuery Mobile: Touch-Optimized Web Framework for Smartphones & Tablets
A unified user interface system across all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design. Alpha Release Notes
Seriously cross-platform & cross-device
jQuery mobile framework takes the "write less, do more" mantra to the next level: Instead of writing unique apps for each mobile device or OS, the jQuery mobile framework will allow you to design a single highly branded and customized web application that will work on all popular smartphone and tablet platforms. Device support grid
iOS
Android
BlackBerry™
Bada
Windows® Phone
Palm webOS™
Symbian
MeeGo™
Touch-optimized layouts & UI widgets
Our aim is to provide tools to build dynamic touch interfaces that will adapt gracefully to a range of device form factors. The system will include both layouts (lists, detail panes, overlays) and a rich set of form controls and UI widgets (toggles, sliders, tabs). Demos
Themable designs: Bigger and better
To make building mobile themes easy, we’re dramatically expanding the CSS framework to have the power to design full applications. For more polished visuals without the bloat, we added support for more CSS3 properties liketext-shadow, box-shadow, and gradients.
Demo Video
Getting started with JQueryMobile
There are two parts to jQueryMobile
jQuery - (Event Handling, DOM Manipulation and Ajax)
jQuery Mobile UI
jQuery - ( Event Handling, DOM Manipulation and Ajax)
This is out of scope for this Article. Please refer to w3c Tutorial on jQuery - http://www.w3schools.com/jquery/default.asp
jQuery Mobile UI
jQuery Mobile Declarative UI
This is the best part about jQuery Mobile. The UI is not declared by using HTML 5 style "data-role". This makes the UI development a breeze. Building a prototype of jQuery Mobile UI (wireframe) would not require any coding, but just html tags.
Lets try to build the following Page in Phone Gap
Step 1 - Include needed Javascript and CSS
<head>
<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />
<script src="jquery-1.4.3.min.js"></script>
<script src="jquery.mobile-1.0a1.min.js"></script>
</head>
Step 2 - Declare different Pages
home is the first screenshot and search is the second screen shot.
<body>
<div data-role="page" id="home">
.....
</div>
<div data-role="page" id="search">
.....
</div>
<div data-role="page" id="recent">
.....
</div>
</body>
Step 3 - Declare Header and Page Navigation
<body>
<div data-role="page" id="home">
<div data-role="header"> <!-- This div with data-role is the header, shown in the black -->
<h1>AlternativeTo Home</h1>
</div>
<div data-role="content"> <!-- This div is the body of the page -->
<p>Find Alternatives To Your favourite Softwares </p>
<p><a href="#search" data-role="button">Search Alternatives</a></p> <!-- navigation button's href points to other page -->
<p><a href="#recent" data-role="button">Recent Alternatives</a></p>
</div>
</div>
<div data-role="page" id="search">
<div data-role="content">
<ul data-role="listview" id="list"> <!-- Special Widget which is List View to show data in a list -->
</ul>
</div>
</div>
</body>
jQuery Mobile API
The jQuery Mobile API talks about Page Loading, Transition, Dialog box handling, List View manipulation, item click etc.
Complete API reference - http://jquerymobile.com/demos/1.0a3/
JQueryMobile + PhoneGap
Boot Events
The main thing when using any Javascript library is to be handle the library boot strap event. A Boot strap event is when js library hells that it is ok to start using its api
A Boot strap event handling in case of jquery is the as follows
$(document).ready(function() {
//Its ok to use all jquery functions here
});
A Boot strap event handling in case of jQuery mobile is as follows (read more here)
$(document).bind("deviceready", function(){
});
or
document.addEventListener("deviceready", onDeviceReady, false);
These bootstraps need to be chained (i,e one calling another one), in order to properly bootstrap both jquery/jquerymobile and phonegap.
Ideally following should be enough ( PS- I need to verify the following code)
$(document).ready(function() {
$(document).bind("deviceready", function(){
});
});
Rest of Integration
The Rest of the Integration is using jQuery selector, event handling to call jQueryMobile and phonegap api.
Demo Apps
Following is the Demo App, with complete index.html file of the UI
Source Code
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-0.9.3.js"></script>
<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />
<script src="jquery-1.4.3.min.js"></script>
<script src="jquery.mobile-1.0a1.min.js"></script>
<script type="text/javascript">
$( function() {
$('#searchButton').click(function() {
$.getJSON('http://api.alternativeto.net/software/'+$('#searchBox').val()+'/?count=15',
function(data) {
var items=data.Items;
var list = $('#list');
list.html("");
$.each(items, function(key, val) {
list.append(
$(document.createElement('li')).html(val.Name)
);
});
list.listview("destroy").listview()
});
});
document.addEventListener("deviceready", onDeviceReady, false);
} );
function reachableCallback(reachability) {
// There is no consistency on the format of reachability
var networkState = reachability.code || reachability;
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[networkState]);
}
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
navigator.network.isReachable('phonegap.com', reachableCallback);
}
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>AlternativeTo Home</h1>
</div>
<div data-role="content">
<p>Find Alternatives To Your favourite Softwares </p>
<p><a href="#search" data-role="button">Search Alternatives</a></p>
<p><a href="#recent" data-role="button">Recent Alternatives</a></p>
</div>
</div>
<div data-role="page" id="search">
<div data-role="header" data-position="fixed">
<h1>Search Alternatives</h1>
<div class="class= ui-body ui-body-b">
<input type="text" name="search" id="searchBox" value="" data-theme="a" />
<button type="submit" data-theme="a" id="searchButton">Search</button>
</div>
</div>
<div data-role="content">
<ul data-role="listview" id="list">
</ul>
</div>
</div>
<div data-role="page" id="recent">
<div data-role="header">
<h1> Recent Alternatives</h1>
</div>
<div data-role="content">
<p>This app rocks!</p>
</div>
</div>
</body>
</html>
Download Demo Source
Download Demo Source here - PhoneGap.zip
This is a working Demo of PhoneGap Client of site - http://alternativeto.net
Issues to watch out
The issue you will notice first and not like is that of ListView with header and footer.
Here is an example
Notice the scrollbar starting from top of page and going it the bottom
Notice the header missing in the second image, (it is missing because it has moved up)
Ideally we would want
Scroll to start below header and end above footer
Header and Footer to be fixed
Fortunately, the fix for this could be provided very soon. Here is an experimental source of jQuery mobile handling the issue - http://jquerymobile.com/test/experiments/scrollview
I would wait for this fix and still bet on jQuery Mobile.
Following is an extract from jQueryMobile site -
jQuery Mobile: Touch-Optimized Web Framework for Smartphones & Tablets
A unified user interface system across all popular mobile device platforms, built on the rock-solid jQuery and jQuery UI foundation. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design. Alpha Release Notes
Seriously cross-platform & cross-device
jQuery mobile framework takes the "write less, do more" mantra to the next level: Instead of writing unique apps for each mobile device or OS, the jQuery mobile framework will allow you to design a single highly branded and customized web application that will work on all popular smartphone and tablet platforms. Device support grid
iOS
Android
BlackBerry™
Bada
Windows® Phone
Palm webOS™
Symbian
MeeGo™
Touch-optimized layouts & UI widgets
Our aim is to provide tools to build dynamic touch interfaces that will adapt gracefully to a range of device form factors. The system will include both layouts (lists, detail panes, overlays) and a rich set of form controls and UI widgets (toggles, sliders, tabs). Demos
Themable designs: Bigger and better
To make building mobile themes easy, we’re dramatically expanding the CSS framework to have the power to design full applications. For more polished visuals without the bloat, we added support for more CSS3 properties liketext-shadow, box-shadow, and gradients.
Demo Video
Getting started with JQueryMobile
There are two parts to jQueryMobile
jQuery - (Event Handling, DOM Manipulation and Ajax)
jQuery Mobile UI
jQuery - ( Event Handling, DOM Manipulation and Ajax)
This is out of scope for this Article. Please refer to w3c Tutorial on jQuery - http://www.w3schools.com/jquery/default.asp
jQuery Mobile UI
jQuery Mobile Declarative UI
This is the best part about jQuery Mobile. The UI is not declared by using HTML 5 style "data-role". This makes the UI development a breeze. Building a prototype of jQuery Mobile UI (wireframe) would not require any coding, but just html tags.
Lets try to build the following Page in Phone Gap
Step 1 - Include needed Javascript and CSS
<head>
<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />
<script src="jquery-1.4.3.min.js"></script>
<script src="jquery.mobile-1.0a1.min.js"></script>
</head>
Step 2 - Declare different Pages
home is the first screenshot and search is the second screen shot.
<body>
<div data-role="page" id="home">
.....
</div>
<div data-role="page" id="search">
.....
</div>
<div data-role="page" id="recent">
.....
</div>
</body>
Step 3 - Declare Header and Page Navigation
<body>
<div data-role="page" id="home">
<div data-role="header"> <!-- This div with data-role is the header, shown in the black -->
<h1>AlternativeTo Home</h1>
</div>
<div data-role="content"> <!-- This div is the body of the page -->
<p>Find Alternatives To Your favourite Softwares </p>
<p><a href="#search" data-role="button">Search Alternatives</a></p> <!-- navigation button's href points to other page -->
<p><a href="#recent" data-role="button">Recent Alternatives</a></p>
</div>
</div>
<div data-role="page" id="search">
<div data-role="content">
<ul data-role="listview" id="list"> <!-- Special Widget which is List View to show data in a list -->
</ul>
</div>
</div>
</body>
jQuery Mobile API
The jQuery Mobile API talks about Page Loading, Transition, Dialog box handling, List View manipulation, item click etc.
Complete API reference - http://jquerymobile.com/demos/1.0a3/
JQueryMobile + PhoneGap
Boot Events
The main thing when using any Javascript library is to be handle the library boot strap event. A Boot strap event is when js library hells that it is ok to start using its api
A Boot strap event handling in case of jquery is the as follows
$(document).ready(function() {
//Its ok to use all jquery functions here
});
A Boot strap event handling in case of jQuery mobile is as follows (read more here)
$(document).bind("deviceready", function(){
});
or
document.addEventListener("deviceready", onDeviceReady, false);
These bootstraps need to be chained (i,e one calling another one), in order to properly bootstrap both jquery/jquerymobile and phonegap.
Ideally following should be enough ( PS- I need to verify the following code)
$(document).ready(function() {
$(document).bind("deviceready", function(){
});
});
Rest of Integration
The Rest of the Integration is using jQuery selector, event handling to call jQueryMobile and phonegap api.
Demo Apps
Following is the Demo App, with complete index.html file of the UI
Source Code
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-0.9.3.js"></script>
<link rel="stylesheet" href="/jquery.mobile-1.0a1.min.css" />
<script src="jquery-1.4.3.min.js"></script>
<script src="jquery.mobile-1.0a1.min.js"></script>
<script type="text/javascript">
$( function() {
$('#searchButton').click(function() {
$.getJSON('http://api.alternativeto.net/software/'+$('#searchBox').val()+'/?count=15',
function(data) {
var items=data.Items;
var list = $('#list');
list.html("");
$.each(items, function(key, val) {
list.append(
$(document.createElement('li')).html(val.Name)
);
});
list.listview("destroy").listview()
});
});
document.addEventListener("deviceready", onDeviceReady, false);
} );
function reachableCallback(reachability) {
// There is no consistency on the format of reachability
var networkState = reachability.code || reachability;
var states = {};
states[NetworkStatus.NOT_REACHABLE] = 'No network connection';
states[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
states[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
alert('Connection type: ' + states[networkState]);
}
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
navigator.network.isReachable('phonegap.com', reachableCallback);
}
</script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>AlternativeTo Home</h1>
</div>
<div data-role="content">
<p>Find Alternatives To Your favourite Softwares </p>
<p><a href="#search" data-role="button">Search Alternatives</a></p>
<p><a href="#recent" data-role="button">Recent Alternatives</a></p>
</div>
</div>
<div data-role="page" id="search">
<div data-role="header" data-position="fixed">
<h1>Search Alternatives</h1>
<div class="class= ui-body ui-body-b">
<input type="text" name="search" id="searchBox" value="" data-theme="a" />
<button type="submit" data-theme="a" id="searchButton">Search</button>
</div>
</div>
<div data-role="content">
<ul data-role="listview" id="list">
</ul>
</div>
</div>
<div data-role="page" id="recent">
<div data-role="header">
<h1> Recent Alternatives</h1>
</div>
<div data-role="content">
<p>This app rocks!</p>
</div>
</div>
</body>
</html>
Download Demo Source
Download Demo Source here - PhoneGap.zip
This is a working Demo of PhoneGap Client of site - http://alternativeto.net
Issues to watch out
The issue you will notice first and not like is that of ListView with header and footer.
Here is an example
Notice the scrollbar starting from top of page and going it the bottom
Notice the header missing in the second image, (it is missing because it has moved up)
Ideally we would want
Scroll to start below header and end above footer
Header and Footer to be fixed
Fortunately, the fix for this could be provided very soon. Here is an experimental source of jQuery mobile handling the issue - http://jquerymobile.com/test/experiments/scrollview
I would wait for this fix and still bet on jQuery Mobile.
发表评论
-
linux shell date用法
2011-09-22 09:53 1374使用date命令转换基础时间秒为年月日: 命令为: date ... -
VSFTPD全攻略
2011-09-19 17:23 855/etc/vsftpd/vsftpd.conf文件 ... -
linux下添加,删除,修改,查看用户和用户组
2011-09-19 10:44 893一,组操作 1,创建组 groupadd test 增加一个 ... -
VSFTP虚拟用户创建方法
2011-09-19 10:29 989yum -y install vsftpd* yum -y i ... -
借助 unoconv 批量转 xls 到 pdf文件
2010-05-10 14:13 1968因为公司的一些业务需 ... -
Windows服务器或vps远程桌面黑屏/蓝屏
2010-05-04 11:44 4001解决办法1: 远程桌面连接-》选项-》高级-》去掉“主题”和 ... -
ubuntu中安装PHP,Apache,MySQL
2010-03-17 14:45 23311、安装Apache服务 sudo apt-get insta ... -
php GZIP javascript
2009-12-31 17:58 1035<?php ob_start('ob_gzhan ... -
ANT-build.xml文件详解
2009-12-01 13:42 1009Ant的概念 可能有些读者并不理解什么是Ant以及如何 ... -
css pre 自动换行的问题
2009-11-05 12:24 1348本站文章中使用了 pre 格式输出 代码。 而浏览器默认是强制 ... -
实战 Comet 应用程序开发
2009-10-26 13:58 902级别: 中级 成 富 (ch ... -
Comet:基于 HTTP 长连接的“服务器推”技术
2009-10-26 13:49 603周 婷 (zhouting@cn.ibm.com) ...
相关推荐
原书名:jQuery, jQuery UI, and jQuery Mobile: Recipes and Examples 原出版社: Addison-Wesley Professional 作者: (荷)Adriaan de Jonge (美)Phil Dutson 译者: 包勇明 程学彬 出版社:人民邮电出版社 ...
资源名称:jQuery、jQuery UI及jQuery Mobile技巧与示例内容简介:《jQuery、jQuery UI及jQuery Mobile技巧与示例》包括jQuery、jQuery UI、jQuery Mobile以及jQuery插件四部分内容。第一部分介绍jQuery核心库,从...
图书的源代部分; 还有由于容量的原因, 视频和web实例图片没有上传. 《jQuery全能权威指南:jQuery Core+jQuery Plugin+...、jQuery UI、jQuery Mobile以及大量第三方的插件库和2800多个应用jQuery技术的网页参考。
JQueryMobile.js插件 html5技术模仿移动手机页面开发 UI的汇总
jQuery Mobile 是用于创建移动 Web 应用的前端开发框架。 jQuery Mobile 可以应用于智能手机与平板电脑。 jQuery Mobile 使用 HTML5 & CSS3 最小的脚本来布局网页。
You begin with simple HTML and quickly enhance it using jQuery Mobile for incredible mobile-optimized sites. Start by learning the building blocks of jQuery Mobile’s component-driven design. Dig ...
jQuery Mobile不仅给主流移动平台带来jQuery核心库,而且还发布了一个完整统一的jQuery移动UI框架。 jQuery Mobile 1.0构建于jQuery核心1.6.4。需要注意的是,虽然jQuery 1.7已经发布了,不过目前jQuery Mobile仍...
webapp界面UI框架Sencha Touch 是WEB APP的界面UI组件库,明显比jquery Mobile快.zip
2.jQuery Mobile 构建于 jQuery 以及 jQuery UI类库之上,如果您了解 jQuery,您可以很容易的学习 jQuery Mobile。 3.jQuery Mobile 使用了极少的 HTML5、CSS3、JavaScript 和 AJAX 脚本代码来完成页面的布局渲染。...
jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库jquery ui库
jQuery mobile相册的一种样式
jQuery Mobile 不仅会给主流移动平台带来jQuery核心库,而且会发布一个完整统一的jQuery移动UI框架。支持全球主流的移动平台。jQuery Mobile开发团队说:能开发这个项目,我们非常兴奋。移动Web太需要一个跨浏览器的...
作为jQuery Mobile的入门级读物,《jQuery Mobile快速入门》以示例方式讲解了jQuery Mobile的基本知识和核心特性,内容系统全面,便于理解。 《jQuery Mobile快速入门》总共分为10章,内容包括jQuery Mobile的基础...
jQuery、jQuery UI及jQuery Mobile技巧与示例
本资源以Hello Word为例,里面包含了jQuery Mobile框架所需要的部署文件。
JQUERYMOBILE 提示框 用语JQUERYMOBILE 移动开发的提示框
jQuery Mobile开发的移动新闻阅读器,HTML5技术配合jQuery MobilejQuery Mobile jqm 新闻阅读器 jqm图标更换 jQuery Mobile jqm 新闻阅读器 jqm自定义按钮的图片以及header和footer的定位
jQuery Mobile快速入门.pdf