Click here to Skip to main content
13,145,603 members (46,134 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 2 Oct 2010

Forward Navigation Via Toolbar Buttons

, 2 Oct 2010
Rate this:
Please Sign up or sign in to vote.
How to use the toolbar buttons for forward navigation in SmartPhones.


In this example, we will learn to use the toolbar buttons for forward navigation. To understand how it is done, let’s create a small application with six panels: Home, Categories, Subcategories, Select Books, Items in Cart, and Checking Out. Let’s assume that the IDs assigned to the six panels are home, bookscategories, subcategories, booksdisplay, showcart, and checkout, respectively. The purpose of each panels is as follows:

  1. Home—The first panel (ID home) that appears on execution of the application (see Figure 1.1 (a)).
  2. Categories—This panel (ID bookscategories) displays the book categories when the Books list item is selected from the Home panel (see Figure 1.1(b))
  3. Subcategories—This panel (ID subcategories) displays book subcategories when a book category is selected from the Categories panel (see Figure 1.1(c)).
  4. Select Books—This panel (ID booksdisplay) displays the books belonging to the selected category and subcategory. The panel appears when a subcategory from the Subcategories panel is selected. From this panel, the user can select books to be added to the cart (see Figure 1.2 (a)).
  5. Note: The list items that appear in the Categories, Subcategories, and Select Books panels are hard-coded, and are just dummies for the time being.

  6. Items in Cart—This panel (ID showcart) displays the books in the cart. For the time being, only dummy books selected will be in the cart. This panel has a Checkout button, which jumps to the Checking Out panel (see Figure 1.2 (b)).
  7. Note: For now, cart contents are hard-coded.

  8. Checking Out—This is the last panel of the checkout process, and only has a Back button for returning to the previous screen (see Figure 1.2 (c)).

Figure 1.1. (a) Home panel with Show Cart button (b)  Categories panel showing book categories (c) Subcategories panel showing book subcategories

Figure 1.2. (a) Select Books panel showing books in the selected category and subcategory (b)  Items in the Cart panel, and the Back and Checkout buttons (c) Checking Out panel

We can create the Back buttons in all the screen panels by adding hyperlinks to the toolbars with the class name back. These HREF hyperlinks all point to #, which simply jumps to the first previous page in the in page history.

The only problem we face is making the Show Cart and Checkout buttons work. But before we can deal with actual functionality, we first have to learn how to put buttons on the right side of the toolbar.

The back and cancel buttons appear on the left side of the toolbar. Only buttons with the button class name appear on the right side. To make the button jump to a panel with a specific ID, we need to set the button href to point to it. You might think, at this point, that the code for a right-side button that navigates to the showcart ID would look like this:

<a class="button " href="#showcart">Show Cart</a>

Although the code appears to be correct, it won’t actually do what we want it to, because no animation has been specified in the hyperlink. The default slide animation won’t work with this code fragment. It’s a simple matter, though, to specify any of the other animation effects that will work: slideup, dissolve, fade, flip, pop, swap, and cube.

Functional code for the showcart ID, using the slideup animation is:

<a class="button slideup" href="#showcart">Show Cart</a>

Similarly, the following fragment creates a Checkout button on the right side of the toolbar that jumps to the checkout panel with a flip animation:

<a class="button flip" href="#checkout">Checkout</a>

The complete code is shown in Listing 1.1.

Listing 1.1. Forward and reverse navigation
       <title>Book Store</title>
       <link type="text/css" rel="stylesheet" media="screen" href="jqtouch/jqtouch.css">
       <link type="text/css" rel="stylesheet" media="screen" 

       <script type="text/javascript" src="jqtouch/jquery.1.3.2.min.js"></script>
       <script type="text/javascript" src="jqtouch/jqtouch.js"></script>
       <script type="text/javascript">
          var jQT = new $.jQTouch();
       <div id="home">
           <div class="toolbar">
               <a class="button slideup" href="#showcart">Show Cart</a>
           <ul class="rounded">
               <li class="arrow"><a href="#bookscategories">Books</a></li>
       <div id="bookscategories">
           <div class="toolbar">
               <a class="back"  href="#">Home</a>
           <ul class="rounded">
               <li class="arrow"><a  href="#subcategories">Literature & Fiction</a></li>
               <li class="arrow"><a  href="#subcategories">Home & Garden</a></li>
               <li class="arrow"><a  href="#subcategories">Computers & Internet</a></li>
               <li class="arrow"><a  href="#subcategories">Cooking, Food & Wine</a></li>
       <div id="subcategories">
          <div class="toolbar">
               <a class="back"  href="#">Back</a> 
           <ul class="rounded">
               <li class="arrow"><a href="#booksdisplay">Subcategory1</a></li>
               <li class="arrow"><a href="#booksdisplay">Subcategory2</a></li>
               <li class="arrow"><a href="#booksdisplay">Subcategory3</a></li>
       <div id="booksdisplay">
           <div class="toolbar">
               <a class="back"  href="#" >Back</a> 
               <h1>Select Books</h1>  
           <ul class="rounded">
               <li class="arrow"><a href="#showcart">Book 1</a></li>
               <li class="arrow"><a href="#showcart">Book 2</a></li>
               <li class="arrow"><a href="#showcart">Book 3</a></li>
               <li class="arrow"><a href="#showcart">Book 3</a></li>
       <div id="showcart">
           <div class="toolbar">
               <a  class="back" href="#" >Back</a> 
               <a class="button flip" href="#checkout">Checkout</a>
               <h1></h1>  
           <p> Book1 by author xyz </p>
           <p> Book2 by author pqr </p>
       <div id="checkout">
           <div class="toolbar">
               <a  class="back" href="#">Back</a>
               <h1>Checking Out</h1>  
           <p> You have not Signed Up yet </p>

Note: Buttons of class back or cancel may only appear on the left side of a toolbar. Only buttons of class button may appear on the right.

For more information, refer to my book: “Beginning Web Development for SmartPhones: Developing Web Applications with PHP, MySQL and jQTouch”, available at Amazon.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Web Developer Microchip Computer Education (M.C.E)
India India
B.M.Harwani is founder and owner of Microchip Computer Education (MCE), based in Ajmer, India that provides computer education in all programming and web developing platforms. He graduated with a BE in computer engineering from the University of Pune, and also has a 'C' Level (master's diploma in computer technology) from DOEACC, Government Of India. Being involved in teaching field for over 16 years, he has developed the art of explaining even the most complicated topics in a straight forward and easily understandable fashion. He has written several books on various subjects that includes JSP, JSF, EJB, PHP, .Net, Joomla, jQuery and Smartphones. To know more, visit

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170915.1 | Last Updated 2 Oct 2010
Article Copyright 2010 by bmharwani
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid