You are previewing jQuery, jQuery UI, and jQuery Mobile: Recipes and Examples.
O'Reilly logo
jQuery, jQuery UI, and jQuery Mobile: Recipes and Examples

Book Description

100+ Practical jQuery Recipes for Solving Your Real-World Web and Mobile Development Challenges!

jQuery makes it easier than ever for developers to build exceptionally robust, cross-platform websites and mobile apps. jQuery, jQuery UI, and jQuery Mobile: Recipes and Examples is a practical “cookbook,” packed with realistic, easy-to-use solutions for making the most of jQuery Core, jQuery UI, plugins, and jQuery Mobile.

This guide brings together more than one hundred self-contained, downloadable examples, each with an in-depth explanation of how the code works and how to adapt it for your own needs. Pioneering web/mobile developers Adriaan de Jonge and Phil Dutson present examples you can apply immediately in virtually any web or mobile app, and with any server-side platform, including PHP, .NET, Java, Ruby, Node.js, or Python. This extremely useful guide will help you 

  • Test browser support and provide for graceful degradation

  • Fine-tune DOM element selection and manipulate your site’s DOM structure

  • Master the newest techniques for event handling and binding

  • Communicate with web servers: AJAX, page errors, redirects, XML, and more

  • Use advanced UI widgets, from accordions and autocomplete to sliders and tabs

  • Build mobile-optimized sites with the jQuery Mobile library

  • Write and smoothly incorporate new plugins

  • Integrate powerful third-party plugins, such as the Twitter Bootstrap framework 

  • The authors’ proven “code first, explain later” approach supports developers at all levels who want to start experimenting immediately. Their exceptionally readable examples never take shortcuts or compromise quality,and their detailed walk-throughs are ideal for anyone who wants to thoroughly understand their code. If you have a working knowledge of HTML, CSS, and basic JavaScript, you’ll feel right at home immediately; if not, de Jonge and Dutson’s careful explanations and full HTML page layout examples will get you up to speed quickly.

    Covers jQuery 1.6.4 and 1.7, with Tips for 1.8

    Table of Contents

    1. Title Page
    2. Copyright Page
    3. Praise for jQuery, jQuery UI, and jQuery Mobile
    4. Dedication Page
    5. Contents at a Glance
    6. Contents
    7. Preface
      1. Why a Recipe and Example Book on jQuery?
      2. Who This Book Is For
      3. How to Use This Book
      4. Book Structure
      5. Additional Resources
    8. Acknowledgments
    9. About the Authors
    10. Part I: Core
      1. Chapter 1. Getting Started with jQuery
        1. Recipe: Introducing the Basic Usage of jQuery
        2. Recipe: Using jQuery with Other Libraries
        3. Recipe: Determining the jQuery Version
        4. Recipe: Iterating Arrays with each()
        5. Recipe: Manipulating Arrays by Using map()
        6. Recipe: Working with Arrays of Elements
        7. Recipe: Getting the Position of an Element by Using index()
        8. Recipe: Finding Elements in an Array by Using grep()
        9. Recipe: Determining the Size of an Element Set by Using length()
        10. Recipe: Retrieving HTML5 data- Attributes
        11. Recipe: Storing Element Data by Using data()
        12. Recipe: Removing Element Data by Using removeData()
        13. Recipe: Testing and Manipulating Variables
        14. Recipe: Extending Objects by Using extend()
        15. Recipe: Serializing the Data in a Form
        16. Recipe: Testing Browsers for Feature Support
        17. Summary
      2. Chapter 2. Selecting Elements
        1. Recipe: Combining Two Element Sets by Using add()
        2. Recipe: Refining the Selection by Using filter()
        3. Recipe: Selecting Descendants by Using find() and children()
        4. Recipe: Selecting Elements by Using has() and Testing by Using is()
        5. Recipe: Selecting Form Elements by Using Pseudo-Selectors
        6. Recipe: Nesting Selectors
        7. Recipe: Emulating a CSS Hover Selector
        8. Recipe: Selecting on Text by Using contains()
        9. Example: Highlighting a Single Word
        10. Recipe: Creating Custom Selectors
        11. Recipe: Scoping the Selection Context
        12. Summary
      3. Chapter 3. Modifying the Page
        1. Recipe: Adding Classes
        2. Example: Removing Classes
        3. Recipe: Generating Class Names
        4. Recipe: Changing Properties and Attributes
        5. Recipe: Changing the HTML Contained within an Element
        6. Recipe: Adding Content by Using append() and appendTo()
        7. Example: Appending the Outcome of a Function
        8. Recipe: Adding Content by Using prepend() and prependTo()
        9. Recipe: Generating HTML Dynamically by Using jQuery
        10. Recipe: Attaching and Detaching Elements
        11. Recipe: Copying Elements by Using clone()
        12. Recipe: Inserting Elements at Specific Positions
        13. Example: Moving Items Up and Down the List
        14. Recipe: Removing Elements
        15. Recipe: Wrapping and Unwrapping Elements
        16. Summary
      4. Chapter 4. Listening and Responding to Events
        1. Recipe: Listening to Mouse Events
        2. Example: Drawing on a Canvas
        3. Recipe: Listening to Keyboard Events
        4. Recipe: Listening to Form Events
        5. Recipe: Listening to Scroll Events
        6. Recipe: Adding Central Event Listeners by Using live() and die()
        7. Recipe: Delegating Events to Specific Ancestor Elements by Using delegate()
        8. Recipe: Changing the Execution Context of a Function by Using proxy()
        9. Summary
      5. Chapter 5. Communicating with the Server
        1. Recipe: Setting Up an Example Server in Node.js
        2. Recipe: Performing a GET Request
        3. Recipe: Loading HTML Directly
        4. Recipe: Handling the Result by Using Promises
        5. Recipe: Handling Server Errors
        6. Recipe: Catching Page-not-Found Results
        7. Recipe: Handling Page Redirects
        8. Recipe: Setting Request Timeouts
        9. Recipe: Passing HTTP Headers
        10. Example: Validating Form Input on the Server Side
        11. Recipe: Loading XML
        12. Recipe: Listening to AJAX Events
        13. Recipe: Reading JSONP from an External Server
        14. Summary
    11. Part II: UI
      1. Chapter 6. Interacting with the User
        1. Downloading and Installing jQuery UI
        2. Recipe: Dragging Elements
        3. Recipe: Dropping Elements
        4. Recipe: Changing the Order of Elements by Using Sortable
        5. Example: Sorting Elements in a Tree Structure
        6. Recipe: Selecting Elements in an Unordered List
        7. Example: Selecting Elements in a Tree Structure
        8. Recipe: Resizing Elements
        9. Summary
      2. Chapter 7. Interacting with Widgets
        1. Recipe: Grouping Content by Using the Accordion
        2. Recipe: Suggesting Input Values by Using Autocomplete
        3. Recipe: Transforming Elements into Buttons
        4. Example: Styling Radio Buttons by Using a Buttonset
        5. Recipe: Choosing Dates by Using the Datepicker
        6. Recipe: Attracting Attention with the Dialog
        7. Recipe: Displaying Status of a Process by Using the Progressbar
        8. Recipe: Retrieving Numbers by Using a Slider
        9. Recipe: Navigating a Page by Using Tabs
        10. Summary
    12. Part III: Mobile
      1. Chapter 8. Changing the Look and Feel
        1. Changing the Styling of jQuery UI Components
        2. Creating Animations by Using jQuery Core
        3. Recipe: Animating Colors by Using jQuery UI
        4. Recipe: Hiding Elements by Using Fade and Slide in jQuery Core
        5. Recipe: Adding Graphical Effects by Using jQuery UI
        6. Recipe: Animating Addition and Removal of CSS Classes by Using jQuery UI
        7. Recipe: Displaying all Easing Functions in jQuery UI as Charts
        8. Recipe: Displaying All Icons in jQuery UI
        9. Recipe: Executing Code at the End of an Animation with a Promise
        10. Recipe: Executing Code Within Animations by Using Queue and Dequeue
        11. Summary
      2. Chapter 9. Navigating Pages by Using jQuery Mobile
        1. Recipe: Setting Up jQuery Mobile Basics
        2. Recipe: Serving Multiple Pages from a Single HTML File
        3. Recipe: Changing the Title Element
        4. Recipe: Loading External Pages Using AJAX
        5. Recipe: Displaying Page Loading Messages
        6. Recipe: Linking to External Pages without AJAX
        7. Recipe: Specifying the Transition Animation
        8. Recipe: Specifying Custom Transition Animations
        9. Recipe: Listening to Mobile Events
        10. Recipe: Generating Back Buttons
        11. Recipe: Adding Footers to the Bottom of the Page
        12. Recipe: Fixing the Footer Across Pages
        13. Recipe: Keeping the Footer in a Fixed Position
        14. Recipe: Hiding and Showing the Footer
        15. Recipe: Optimizing Headers and Footers for Fullscreen View
        16. Recipe: Changing Color Schemes with Themes
        17. Recipe: Using Multiple Columns
        18. Recipe: Changing Pages by Using JavaScript Calls
        19. Recipe: Loading Pages by Using JavaScript Calls
        20. Recipe: Attaching Data to DOM Nodes in jQuery Mobile
        21. Recipe: Utilizing jQuery Mobile Helper Functions
        22. Summary
      3. Chapter 10. Interacting with jQuery Mobile
        1. Recipe: Displaying Toolbars Inline in Content
        2. Recipe: Displaying a Warning Bar
        3. Recipe: Adding Menu Bars to Footer Elements
        4. Recipe: Navigating with a Navigation Bar
        5. Recipe: Showing and Hiding Elements by Using Collapsible
        6. Recipe: Adding Accordion Behavior by Using Collapsible Sets
        7. Recipe: Acquiring Basic Text Input by Using Form Fields
        8. Recipe: Acquiring Calendar-Based Input
        9. Recipe: Displaying Input Fields by Using Alternative Keyboards
        10. Recipe: Displaying Specialized Input Fields
        11. Recipe: Acquiring Integers by Using Sliders
        12. Recipe: Setting Binaries with Flip Switches
        13. Recipe: Selecting a Single Element by Using Radio Buttons
        14. Recipe: Selecting Multiple Elements by Using Check Boxes
        15. Recipe: Selecting Elements from Drop-Down Lists
        16. Recipe: Displaying Native Forms by Using jQuery Mobile Off
        17. Recipe: Displaying Lists of Elements
        18. Recipe: Filtering List Elements
        19. Recipe: Grouping Form Elements in Lists
        20. Summary
    13. Part IV: Plugins
      1. Chapter 11. Creating Plugins
        1. Recipe: Setting Up a Simple Static Plugin
        2. Recipe: Creating Simple Context-Aware Plugins
        3. Recipe: Chaining jQuery Functions and Plugins
        4. Recipe: Parameterizing Plugins
        5. Recipe: Providing Default Parameters
        6. Recipe: Operating the Plugin by Using Methods
        7. Recipe: Creating a Plugin that Creates Plugins
        8. Recipe: Registering and Invoking Callback Functions
        9. Recipe: Passing Context to Callback Functions
        10. Recipe: Returning Deferred Objects to Call Separate Callbacks on Success and on Error
        11. Recipe: Returning a Promise to Protect Internals
        12. Recipe: Demonstrating the Promise(d) Protection
        13. Recipe: Using Promise to Control Flow Structures
        14. Recipe: Visualizing Progress Before the Final Callback
        15. Recipe: Providing Context to Callback Functions
        16. Recipe: Providing a Context to Progress Functions
        17. Summary
      2. Chapter 12. Working with Third-Party Plugins
        1. Recipe: Displaying a Modal
        2. Recipe: Using a Drop-Down Menu
        3. Recipe: Using ScrollSpy
        4. Recipe: Toggling Tabs
        5. Recipe: Adding Tooltips
        6. Recipe: Adding a Popover
        7. Recipe: Alerting the User
        8. Recipe: Button Control
        9. Recipe: Collapsing Content
        10. Recipe: Putting Content in a Carousel
        11. Recipe: Using typeahead for Autocomplete
        12. Summary
    14. Index