Jorge Ramon

  • Home
  • New Here?
  • Articles
    • All
    • Sencha Touch
    • jQuery Mobile
    • ExtJS
  • Books
  • About
You are here: Home / Tutorials / jQuery Mobile Tutorials / Creating a Website Using JQuery Mobile, Part 3

Creating a Website Using JQuery Mobile, Part 3

February 7, 2011 7 Comments

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  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  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  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  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  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.

Tagged With: JQuery Mobile Tutorial 7 Comments

Comments

  1. David says

    March 10, 2011 at 12:22 AM

    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

    Reply
    • Jorge says

      March 27, 2011 at 1:51 PM

      You can attach yuor own file David.

      Reply
  2. cognostek says

    July 6, 2011 at 2:23 AM

    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?

    Reply
  3. Andre Venter says

    August 1, 2011 at 6:34 PM

    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

    Reply
  4. Mike says

    October 11, 2011 at 3:15 PM

    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

    Reply
  5. Steve Allen says

    March 18, 2012 at 1:38 PM

    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.

    Reply

Leave a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Free Mobile User Interface Recipes Kit

Free Mobile User Interface Recipes Kit

Sign up to receive my posts via email and get a FREE Mobile User Interface Recipes Kit with mockups packages for three real-world mobile apps. You will save hours of design time when you use the kit to build your own apps.



I will never share your email address.

Get My Books

The beginner's guide to Sencha Touch apps
The beginner's guide to jQuery Mobile apps

Book: How to Build a jQuery Mobile Application

Topics

  • » jQuery Mobile Tutorials
  • » Sencha Touch Tutorials
  • » ExtJS Tutorials
  • » Books
  • » Tools
  • » .Net Tutorials
  • » BlackBerry Tutorials
  • » iOS Tutorials
  • » Node.js Tutorials
  • » Android Training
  • » BlackBerry Training
  • » iOS Training

Search

Contact Me

  •  Email: jorge[AT]jorgeramon.me
  •  Twitter: @MiamiCoder
  •  LinkedIn: Jorge Ramon


Don’t Miss the Free Updates

Receive free updates in your inbox.
Your address is safe with me.

Copyright © 2018 Jorge Ramon · The opinions expressed herein do not represent the views of my employers in any way · Log in