JQuery Mobile is a great UI framework for developing mobile applications, which works by applying progressive enhancements to your clean, semantic HTML, and transform it into rich user interfaces.
In this series I have been showing you how to quickly put together a fictional event website using JQuery Mobile. I have saved the construction of the last two pages, event Schedule and Information, for this article.
The Schedule Page
Below is how I need the Schedule page to look. (Notice that it is simpler than the original version in the first part of this series.)
I will again use JQuery Mobile’s standard boilerplate page template as a reference, adding HTML elements for the leading text and the list of sessions:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Schedule</title> <link href="../jquery-mobile/jquery.mobile-1.0a2.css" rel="stylesheet" type="text/css" /> <link href="css/event.css" rel="stylesheet" type="text/css" /> <script src="../jquery-mobile/jquery-1.4.4.min.js" type="text/javascript"></script> <script src="../jquery-mobile/jquery.mobile-1.0a2.js" type="text/javascript"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1> Schedule</h1> </div> <div data-role="content"> <div id="banner"> <h2> Mobile Dev 2011</h2> </div> <p> There has never been a more exciting time to be a mobile developer. We have one full day of mobile development awesomeness for you!</p> <ul data-role="listview" data-inset="true"> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Keynote</h3> <p class="session-time-speaker"> 9:00 AM - 9:30 AM&nbsp;&nbsp;Speaker B</p> <p> Short introduction to keynote.</p> </div> </li> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Session 2</h3> <p class="session-time-speaker"> 10:00 AM - 10:55 AM&nbsp;&nbsp;Speaker D</p> <p> Short introduction to session.</p> </div> </li> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Session 3</h3> <p class="session-time-speaker"> 11:00 AM - 12:00 AM&nbsp;&nbsp;Speaker A</p> <p> Short introduction to session.</p> </div> </li> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Lunch</h3> <p class="session-time-speaker"> 12:00 PM - 1:30 PM</p> <p> Talk about luch here.</p> </div> </li> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Session 4</h3> <p class="session-time-speaker"> 1:30 PM - 3:00 PM&nbsp;&nbsp;Speaker C, Speaker B</p> <p> Short introduction to session.</p> </div> </li> <li class="list-item-schedule"> <div class="list-item-content-schedule"> <h3> Session 5</h3> <p class="session-time-speaker"> 3:15 PM - 4:30 PM&nbsp;&nbsp;Speaker C, Speaker B</p> <p> Short introduction to session.</p> </div> </li> </ul> </div> </div> </body> </html>
I am using an unordered list to display the sessions, as I did to display the speakers in the Speakers page. Following the philosophy of progressive enhancements, the framework takes care of transforming the list into a mobile-friendly list view. I only need to worry about the HTML template used within each li element.
This is how the page looks:
The Information Page
The Information page is where I will display the details about the event’s venue, hotels and transportation:
I will keep this page as simple as possible. You can grab the source code and embellish the page as you see fit.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Information</title> <link href="../jquery-mobile/jquery.mobile-1.0a2.css" rel="stylesheet" type="text/css" /> <link href="css/event.css" rel="stylesheet" type="text/css" /> <script src="../jquery-mobile/jquery-1.4.4.min.js" type="text/javascript"></script> <script src="../jquery-mobile/jquery.mobile-1.0a2.js" type="text/javascript"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1> Information</h1> </div> <div data-role="content"> <div id="banner"> <h2> Mobile Dev 2011</h2> </div> <h3> The Event Venue</h3> <p> Information about the venue.</p> <h3> Hotels</h3> <p> This is the place for hotels information.</p> <h3> Transportation</h3> <p> All about transpoprtation.</p> </div> </div> </body> </html>
The page renders like so:
There is More to JQuery Mobile
If you are new to JQuery Mobile, as you walk through the example’s source code you will notice how fast you can get results using this framework.
In order to make it easy for you to get started, I have deliberately simplified the example, using only a few static HTML pages, and working with the page framework, toolbars and list view elements in JQuery Mobile.
However, there is much more to JQuery Mobile than what I have touched in this series. In upcoming articles I will introduce you to important user interface components such as dialogs, form elements and toolbars, as well as APIs that allow you to work with different touch events and screen orientations.
Downloads
Grab the code from the JQuery Mobile Tutorial repo: MiamiCoder JQuery-Mobile-Tutorial
Want To Learn More?
Check out my How to Build a jQuery Mobile Application EBook. It teaches you how jQuery Mobile works by guiding you, step by step, through the process of building an application. It even explains how to keep application data synchronized with a server.
Hi, I am following your tutorials on the JQuery mobile website, and I am wondering if there is a way to attached another CSS file to it, or if “in-line styling” is possible…in the case that it is not possible how can we change some of the styling in the css
You can attach yuor own file David.
Hi, You have an amazing tutorial, its really helpful. Thanks again. My quick question would be I was unable to get the RSS content of any website to mobile jquery.I have tried it but couldn’t find the answer. Have you tried it or can check if it works for you?
Thank you for a great tutorial.
I have a strange outcome on phones. The site is behaving like a regular web site – very small buttons and text.
You need to zoom in a lot before the text becomes readable.
On iPad and HTCFlyer it works just like you screen shots.
Why not for mobile phones?
I posted it here – lab.think-a-doo.net/MobileConference/index.html
using jquery.mobile-1.0b1.min.js and .css
What event would you use in the speakers page to trigger an event when that page is loaded/displayed? I’m trying to find out how to run some javascript when the user clicks a list item and is taken to a new page. The original page uses the pagecreate event but that doesn’t work for the second page. Thanks
I have seen jquery mobile built sites that have a background image. How would I get that look. I have tried adding a background image in a custom css file to * and to the body, but the jquery info overrides it and the image only shows under – below – the jquery elements. Seems like it should be easy to do.