jQuery Cookbook

Book description

jQuery simplifies building rich, interactive web frontends. Getting started with this JavaScript library is easy, but it can take years to fully realize its breadth and depth; this cookbook shortens the learning curve considerably. With these recipes, you'll learn patterns and practices from 19 leading developers who use jQuery for everything from integrating simple components into websites and applications to developing complex, high-performance user interfaces.

Ideal for newcomers and JavaScript veterans alike, jQuery Cookbook starts with the basics and then moves to practical use cases with tested solutions to common web development hurdles. You also get recipes on advanced topics, such as methods for applying jQuery to large projects.

  • Solve problems involving events, effects, dimensions, forms, themes, and user interface elements
  • Learn how to enhance your forms, and how to position and reposition elements on a page
  • Make the most of jQuery's event management system, including custom events and custom event data
  • Create UI elements-such as tabs, accordions, and modals-from scratch
  • Optimize your code to eliminate bottlenecks and ensure peak performance
  • Learn how to test your jQuery applications

The book's contributors include:

  • Cody Lindley
  • James Padolsey
  • Ralph Whitbeck
  • Jonathan Sharp
  • Michael Geary and Scott González
  • Rebecca Murphey
  • Remy Sharp
  • Ariel Flesler
  • Brian Cherne
  • Jörn Zaefferer
  • Mike Hostetler
  • Nathan Smith
  • Richard D. Worth
  • Maggie Wachs, Scott Jehl, Todd Parker, and Patty Toland
  • Rob Burns

Publisher resources

View/Submit Errata

Table of contents

  1. jQuery Cookbook
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. A Note Regarding Supplemental Files
  4. Foreword
  5. Contributors
    1. Chapter Authors
    2. Tech Editors
  6. Preface
    1. Who This Book Is For
    2. What You’ll Learn
    3. jQuery Style and Conventions
    4. Other Options
    5. If You Have Problems Making Examples Work
    6. If You Like (or Don’t Like) This Book
    7. Conventions Used in This Book
    8. Using Code Examples
    9. Safari® Books Online
    10. How to Contact Us
  7. 1. jQuery Basics
    1. Introduction
      1. Why jQuery?
      2. The jQuery Philosophy
        1. Find some elements and do something with them
        2. Chaining
        3. The jQuery wrapper set
      3. How the jQuery API Is Organized
    2. 1.1. Including the jQuery Library Code in an HTML Page
      1. Problem
      2. Solution
      3. Discussion
    3. 1.2. Executing jQuery/JavaScript Coded After the DOM Has Loaded but Before Complete Page Load
      1. Problem
      2. Solution
      3. Discussion
    4. 1.3. Selecting DOM Elements Using Selectors and the jQuery Function
      1. Problem
      2. Solution
      3. Discussion
    5. 1.4. Selecting DOM Elements Within a Specified Context
      1. Problem
      2. Solution
      3. Discussion
    6. 1.5. Filtering a Wrapper Set of DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    7. 1.6. Finding Descendant Elements Within the Currently Selected Wrapper Set
      1. Problem
      2. Solution
      3. Discussion
    8. 1.7. Returning to the Prior Selection Before a Destructive Change
      1. Problem
      2. Solution
      3. Discussion
    9. 1.8. Including the Previous Selection with the Current Selection
      1. Problem
      2. Solution
      3. Discussion
    10. 1.9. Traversing the DOM Based on Your Current Context to Acquire a New Set of DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    11. 1.10. Creating, Operating on, and Inserting DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    12. 1.11. Removing DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    13. 1.12. Replacing DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    14. 1.13. Cloning DOM Elements
      1. Problem
      2. Solution
      3. Discussion
    15. 1.14. Getting, Setting, and Removing DOM Element Attributes
      1. Problem
      2. Solution
      3. Discussion
    16. 1.15. Getting and Setting HTML Content
      1. Problem
      2. Solution
      3. Discussion
    17. 1.16. Getting and Setting Text Content
      1. Problem
      2. Solution
      3. Discussion
    18. 1.17. Using the $ Alias Without Creating Global Conflicts
      1. Problem
      2. Solution
      3. Discussion
  8. 2. Selecting Elements with jQuery
    1. Introduction
    2. 2.1. Selecting Child Elements Only
      1. Problem
      2. Solution
      3. Discussion
    3. 2.2. Selecting Specific Siblings
      1. Problem
      2. Solution
      3. Discussion
    4. 2.3. Selecting Elements by Index Order
      1. Problem
      2. Solution
      3. Discussion
    5. 2.4. Selecting Elements That Are Currently Animating
      1. Problem
      2. Solution
      3. Discussion
    6. 2.5. Selecting Elements Based on What They Contain
      1. Problem
      2. Solution
      3. Discussion
    7. 2.6. Selecting Elements by What They Don’t Match
      1. Problem
      2. Solution
      3. Discussion
    8. 2.7. Selecting Elements Based on Their Visibility
      1. Problem
      2. Solution
      3. Discussion
    9. 2.8. Selecting Elements Based on Attributes
      1. Problem
      2. Solution
      3. Discussion
    10. 2.9. Selecting Form Elements by Type
      1. Problem
      2. Solution
      3. Discussion
    11. 2.10. Selecting an Element with Specific Characteristics
      1. Problem
      2. Solution
      3. Discussion
    12. 2.11. Using the Context Parameter
      1. Problem
      2. Solution
      3. Discussion
    13. 2.12. Creating a Custom Filter Selector
      1. Problem
      2. Solution
      3. Discussion
  9. 3. Beyond the Basics
    1. Introduction
    2. 3.1. Looping Through a Set of Selected Results
      1. Problem
      2. Solution
      3. Discussion
    3. 3.2. Reducing the Selection Set to a Specified Item
      1. Problem
      2. Solution
      3. Discussion
    4. 3.3. Convert a Selected jQuery Object into a Raw DOM Object
      1. Problem
      2. Solution
      3. Discussion
    5. 3.4. Getting the Index of an Item in a Selection
      1. Problem
      2. Solution
      3. Discussion
    6. 3.5. Making a Unique Array of Values from an Existing Array
      1. Problem
      2. Solution
      3. Discussion
    7. 3.6. Performing an Action on a Subset of the Selected Set
      1. Problem
      2. Solution
      3. Discussion
    8. 3.7. Configuring jQuery Not to Conflict with Other Libraries
      1. Problem
      2. Solution
      3. Discussion
    9. 3.8. Adding Functionality with Plugins
      1. Problem
      2. Solution
      3. Discussion
    10. 3.9. Determining the Exact Query That Was Used
      1. Problem
      2. Solution
      3. Discussion
  10. 4. jQuery Utilities
    1. Introduction
    2. 4.1. Detecting Features with jQuery.support
      1. Problem
      2. Solution
      3. Discussion
    3. 4.2. Iterating Over Arrays and Objects with jQuery.each
      1. Problem
      2. Solution
      3. Discussion
    4. 4.3. Filtering Arrays with jQuery.grep
      1. Problem
      2. Solution
      3. Discussion
    5. 4.4. Iterating and Modifying Array Entries with jQuery.map
      1. Problem
      2. Solution
      3. Discussion
    6. 4.5. Combining Two Arrays with jQuery.merge
      1. Problem
      2. Solution
      3. Discussion
    7. 4.6. Filtering Out Duplicate Array Entries with jQuery.unique
      1. Problem
      2. Solution
      3. Discussion
    8. 4.7. Testing Callback Functions with jQuery.isFunction
      1. Problem
      2. Solution
      3. Discussion
    9. 4.8. Removing Whitespace from Strings or Form Values with jQuery.trim
      1. Problem
      2. Solution
      3. Discussion
    10. 4.9. Attaching Objects and Data to DOM with jQuery.data
      1. Problem
      2. Solution
      3. Discussion
    11. 4.10. Extending Objects with jQuery.extend
      1. Problem
      2. Solution
      3. Discussion
  11. 5. Faster, Simpler, More Fun
    1. Introduction
    2. 5.1. That’s Not jQuery, It’s JavaScript!
      1. Problem
      2. Solution
      3. Discussion
    3. 5.2. What’s Wrong with $(this)?
      1. Problem
      2. Solution
      3. Discussion
    4. 5.3. Removing Redundant Repetition
      1. Problem
      2. Solution 1
      3. Solution 2
      4. Discussion
    5. 5.4. Formatting Your jQuery Chains
      1. Problem
      2. Solution
      3. Discussion
    6. 5.5. Borrowing Code from Other Libraries
      1. Problem
      2. Solution
      3. Discussion
    7. 5.6. Writing a Custom Iterator
      1. Problem
      2. Solution
      3. Discussion
    8. 5.7. Toggling an Attribute
      1. Problem
      2. Solution
      3. Discussion
    9. 5.8. Finding the Bottlenecks
      1. Problem
      2. Solution
      3. Discussion
    10. 5.9. Caching Your jQuery Objects
      1. Problem
      2. Solution
      3. Discussion
    11. 5.10. Writing Faster Selectors
      1. Problem
      2. Solution
      3. Discussion
    12. 5.11. Loading Tables Faster
      1. Problem
      2. Solution
      3. Discussion
    13. 5.12. Coding Bare-Metal Loops
      1. Problem
      2. Solution
      3. Discussion
    14. 5.13. Reducing Name Lookups
      1. Problem
      2. Solution
      3. Discussion
    15. 5.14. Updating the DOM Faster with .innerHTML
      1. Problem
      2. Solution
      3. Discussion
    16. 5.15. Debugging? Break Those Chains
      1. Problem
      2. Solution
      3. Discussion
    17. 5.16. Is It a jQuery Bug?
      1. Problem
      2. Solution
      3. Discussion
    18. 5.17. Tracing into jQuery
      1. Problem 1
      2. Solution 1
      3. Problem 2
      4. Solution 2
      5. Discussion
    19. 5.18. Making Fewer Server Requests
      1. Problem
      2. Solution
      3. Discussion
    20. 5.19. Writing Unobtrusive JavaScript
      1. Problem
      2. Solution
      3. Discussion
    21. 5.20. Using jQuery for Progressive Enhancement
      1. Problem
      2. Solution
      3. Discussion
    22. 5.21. Making Your Pages Accessible
      1. Problem
      2. Solution
      3. Discussion
  12. 6. Dimensions
    1. Introduction
    2. 6.1. Finding the Dimensions of the Window and Document
      1. Problem
      2. Solution
      3. Discussion
    3. 6.2. Finding the Dimensions of an Element
      1. Problem
      2. Solution
      3. Discussion
    4. 6.3. Finding the Offset of an Element
      1. Problem
      2. Solution
      3. Discussion
    5. 6.4. Scrolling an Element into View
      1. Problem
      2. Solution: Scrolling the Whole Window
      3. Solution: Scrolling Inside an Element
    6. 6.5. Determining Whether an Element Is Within the Viewport
      1. Problem
      2. Solution
    7. 6.6. Centering an Element Within the Viewport
      1. Problem
      2. Solution
    8. 6.7. Absolutely Positioning an Element at Its Current Position
      1. Problem
      2. Solution
    9. 6.8. Positioning an Element Relative to Another Element
      1. Problem
      2. Solution
    10. 6.9. Switching Stylesheets Based on Browser Width
      1. Problem
      2. Solutions
      3. Solution 1: Changing the Class on the Body Element
      4. Solution 2: Changing the href Attribute of the Stylesheet That’s Responsible for Size-Related Styling
      5. Solution 3: Include All Size-Related Stylesheets in the Page, but Enable Only One at a Time
      6. Discussion
  13. 7. Effects
    1. Introduction
      1. Animate Method
      2. Animation Speeds
      3. Effects Template
    2. 7.1. Sliding and Fading Elements in and out of View
      1. Problem
      2. Solution
        1. Slide
        2. Fade
        3. Both
      3. Discussion
    3. 7.2. Making Elements Visible by Sliding Them Up
      1. Problem
      2. Solution
        1. HTML
        2. CSS
        3. jQuery
      3. Discussion
    4. 7.3. Creating a Horizontal Accordion
      1. Problem
      2. Solution
        1. HTML
        2. CSS
        3. jQuery
      3. Discussion
    5. 7.4. Simultaneously Sliding and Fading Elements
      1. Solution
      2. Discussion
    6. 7.5. Applying Sequential Effects
      1. Problem
      2. Solution
        1. Manual callback
        2. Automatic sequence
      3. Discussion
    7. 7.6. Determining Whether Elements Are Currently Being Animated
      1. Problem
      2. Solution
      3. Discussion
    8. 7.7. Stopping and Resetting Animations
      1. Problem
      2. Solution
      3. Discussion
    9. 7.8. Using Custom Easing Methods for Effects
      1. Problem
      2. Solution
      3. Discussion
    10. 7.9. Disabling All Effects
      1. Problem
      2. Solution
      3. Discussion
    11. 7.10. Using jQuery UI for Advanced Effects
      1. Problem
      2. Solution
        1. CSS
        2. jQuery
      3. Discussion
  14. 8. Events
    1. Introduction
    2. 8.1. Attaching a Handler to Many Events
      1. Problem
      2. Solution
      3. Discussion
    3. 8.2. Reusing a Handler Function with Different Data
      1. Problem
      2. Solution
      3. Discussion
    4. 8.3. Removing a Whole Set of Event Handlers
      1. Problem
      2. Solution
      3. Discussion
        1. How to bind with a namespace?
        2. How to clean up my plugin?
    5. 8.4. Triggering Specific Event Handlers
      1. Problem
      2. Solution
      3. Discussion
        1. How to trigger handlers with a certain namespace?
        2. How to trigger handlers that do not have a namespace?
    6. 8.5. Passing Dynamic Data to Event Handlers
      1. Problem
      2. Solution
      3. Discussion
        1. Passing extra arguments
          1. Some more examples
        2. Passing a custom event object
        3. What’s the difference with event.data?
    7. 8.6. Accessing an Element ASAP (Before document.ready)
      1. Problem
      2. Solution
      3. Discussion
        1. Hide an element right away (or another style operation)
        2. Bind event handlers to an element ASAP
        3. Any other situation
          1. Polling
          2. Customly positioned scripts
    8. 8.7. Stopping the Handler Execution Loop
      1. Problem
      2. Solution
      3. Discussion
        1. Examples
          1. Simple form validation
          2. Killing all events
        2. Disadvantages of this approach
    9. 8.8. Getting the Correct Element When Using event.target
      1. Problem
      2. Solution
      3. Discussion
    10. 8.9. Avoid Multiple hover() Animations in Parallel
      1. Problem
      2. Solution
      3. Discussion
        1. Example
        2. Not there yet
    11. 8.10. Making Event Handlers Work for Newly Added Elements
      1. Problem
      2. Solution
      3. Discussion
        1. Why do event handlers get lost ?
        2. A little introduction to event delegation
        3. Pros and cons of each approach
          1. Rebinding
          2. Event delegation
        4. Conclusion
  15. 9. Advanced Events
    1. Introduction
    2. 9.1. Getting jQuery to Work When Loaded Dynamically
      1. Problem
      2. Solution
      3. Discussion
        1. What is jQuery.ready()?
        2. Why was this happening?
    3. 9.2. Speeding Up Global Event Triggering
      1. Problem
      2. Solution
      3. Discussion
        1. Pros and cons
        2. Making the listeners functional
    4. 9.3. Creating Your Own Events
      1. Problem
      2. Solution
      3. Discussion
        1. Handling every binding to your event
        2. A real-world example
        3. Existing uses for this feature
    5. 9.4. Letting Event Handlers Provide Needed Data
      1. Problem
      2. Solution
      3. Discussion
        1. How can we do this with jQuery 1.3+?
        2. How this was achieved before jQuery 1.3
        3. Allowing event handlers to prevent actions
    6. 9.5. Creating Event-Driven Plugins
      1. Problem
      2. Solution
      3. Discussion
        1. An example
        2. What happens if an element already has one of these events?
        3. How can I allow others to clean up the added event handlers?
        4. What’s the difference with other approaches?
          1. Allowing the plugin to accept commands
          2. Returning an object with methods
    7. 9.6. Getting Notified When jQuery Methods Are Called
      1. Problem
      2. Solution
      3. Discussion
        1. Overloading the desired method
        2. Triggering an event prior to the execution
        3. Executing the original method
        4. Triggering an event after the execution
        5. Returning the result
        6. Putting it all together
        7. Where to go from here?
    8. 9.7. Using Objects’ Methods as Event Listeners
      1. Problem
      2. Solution
      3. Discussion
        1. Where did the node go?
        2. The example
          1. The objects
          2. Binding the methods
  16. 10. HTML Form Enhancements from Scratch
    1. Introduction
    2. 10.1. Focusing a Text Input on Page Load
      1. Problem
      2. Solution
      3. Discussion
    3. 10.2. Disabling and Enabling Form Elements
      1. Problem
      2. Solution 1
      3. Solution 2
      4. Discussion
    4. 10.3. Selecting Radio Buttons Automatically
      1. Problem
      2. Solution 1
      3. Solution 2
      4. Discussion
    5. 10.4. (De)selecting All Checkboxes Using Dedicated Links
      1. Problem
      2. Solution
      3. Discussion
    6. 10.5. (De)selecting All Checkboxes Using a Single Toggle
      1. Problem
      2. Solution
      3. Discussion
    7. 10.6. Adding and Removing Select Options
      1. Problem
      2. Solution
      3. Discussion
    8. 10.7. Autotabbing Based on Character Count
      1. Problem
      2. Solution
      3. Discussion
    9. 10.8. Displaying Remaining Character Count
      1. Problem
      2. Solution
      3. Discussion
    10. 10.9. Constraining Text Input to Specific Characters
      1. Problem
      2. Solution
      3. Discussion
    11. 10.10. Submitting a Form Using Ajax
      1. Problem
      2. Solution
      3. Discussion
    12. 10.11. Validating Forms
      1. Problem
      2. Solution
      3. Discussion
  17. 11. HTML Form Enhancements with Plugins
    1. Introduction
      1. Basic Approach
    2. 11.1. Validating Forms
      1. Problem
      2. Solution
      3. Discussion
        1. Methods
          1. Custom methods
        2. Rules
          1. Dependencies
          2. Custom expressions
        3. Error messages
          1. Localization
          2. Error element
          3. Layout
        4. Handling the submit
        5. Limitations
    3. 11.2. Creating Masked Input Fields
      1. Problem
      2. Solution
      3. Discussion
        1. Limitations
    4. 11.3. Autocompleting Text Fields
      1. Problem
      2. Solution
      3. Discussion
    5. 11.4. Selecting a Range of Values
      1. Problem
      2. Solution
      3. Discussion
    6. 11.5. Entering a Range-Constrained Value
      1. Problem
      2. Solution
      3. Discussion
        1. Google Maps integration
    7. 11.6. Uploading Files in the Background
      1. Problem
      2. Solution
      3. Discussion
    8. 11.7. Limiting the Length of Text Inputs
      1. Problem
      2. Solution
      3. Discussion
    9. 11.8. Displaying Labels Above Input Fields
      1. Problem
      2. Solution
      3. Discussion
    10. 11.9. Growing an Input with Its Content
      1. Problem
      2. Solution
      3. Discussion
    11. 11.10. Choosing a Date
      1. Problem
      2. Solution
      3. Discussion
        1. Localization
  18. 12. jQuery Plugins
    1. Introduction
    2. 12.1. Where Do You Find jQuery Plugins?
      1. Problem
      2. Solution
      3. Discussion
        1. Search through the jQuery Plugin Repository
        2. Search through Google Code
        3. Search through GitHub
        4. Perform a Google search
        5. Search through SourceForge
    3. 12.2. When Should You Write a jQuery Plugin?
      1. Problem
      2. Solution
      3. Discussion
        1. Build a plugin if there is a potential audience
        2. Know and communicate the level of support you are willing to provide
        3. Plan for participation from others
    4. 12.3. Writing Your First jQuery Plugin
      1. Problem
      2. Solution
        1. Writing a custom jQuery method
        2. Writing a custom jQuery function
      3. Discussion
    5. 12.4. Passing Options into Your Plugin
      1. Problem
      2. Solution
      3. Discussion
    6. 12.5. Using the $ Shortcut in Your Plugin
      1. Problem
      2. Solution
      3. Discussion
    7. 12.6. Including Private Functions in Your Plugin
      1. Problem
      2. Solution
      3. Discussion
    8. 12.7. Supporting the Metadata Plugin
      1. Problem
      2. Solution
      3. Discussion
    9. 12.8. Adding a Static Function to Your Plugin
      1. Problem
      2. Solution
      3. Discussion
    10. 12.9. Unit Testing Your Plugin with QUnit
      1. Problem
      2. Solution
      3. Discussion
  19. 13. Interface Components from Scratch
    1. Introduction
    2. 13.1. Creating Custom Tool Tips
      1. Problem
      2. Solution
        1. Tool tip—HTML code
        2. Tool tip—jQuery code
      3. Discussion
    3. 13.2. Navigating with a File-Tree Expander
      1. Problem
      2. Solution
        1. File tree—HTML code
        2. File tree—jQuery code
      3. Discussion
    4. 13.3. Expanding an Accordion
      1. Problem
      2. Solution
        1. Accordion—HTML code
        2. Accordion—jQuery code
      3. Discussion
    5. 13.4. Tabbing Through a Document
      1. Problem
      2. Solution
        1. Tabs—HTML code
        2. Tabs—jQuery code
      3. Discussion
    6. 13.5. Displaying a Simple Modal Window
      1. Problem
        1. Solution
        2. Modal—HTML code
        3. Modal—jQuery code
      2. Discussion
    7. 13.6. Building Drop-Down Menus
      1. Problem
      2. Solution
        1. Drop-down—HTML code
        2. Drop-down—jQuery code
      3. Discussion
    8. 13.7. Cross-Fading Rotating Images
      1. Problem
      2. Solution
        1. Rotator—HTML code
        2. Rotator—jQuery code
      3. Discussion
    9. 13.8. Sliding Panels
      1. Problem
      2. Solution
        1. Panels—HTML code
        2. Panels—jQuery code
      3. Discussion
  20. 14. User Interfaces with jQuery UI
    1. Introduction
      1. Interactions
      2. Widgets
      3. Effects
      4. Basic Usage
      5. How This Chapter Is Organized
    2. 14.1. Including the Entire jQuery UI Suite
      1. Problem
      2. Solution
      3. Discussion
    3. 14.2. Including an Individual jQuery UI Plugin or Two
      1. Problem
      2. Solution
      3. Discussion
    4. 14.3. Initializing a jQuery UI Plugin with Default Options
      1. Problem
      2. Solution
      3. Discussion
    5. 14.4. Initializing a jQuery UI Plugin with Custom Options
      1. Problem
      2. Solution
      3. Discussion
    6. 14.5. Creating Your Very Own jQuery UI Plugin Defaults
      1. Problem
      2. Solution
      3. Discussion
    7. 14.6. Getting and Setting jQuery UI Plugin Options
      1. Problem
      2. Solution 1: Getting the Value
      3. Solution 2: Setting the Value
      4. Discussion
    8. 14.7. Calling jQuery UI Plugin Methods
      1. Problem
      2. Solution
      3. Discussion
    9. 14.8. Handling jQuery UI Plugin Events
      1. Problem
      2. Solution 1: Pass a Callback Function to the Event Name Option
      3. Solution 2: Bind to the Custom Event Using the Event Type
      4. Discussion
    10. 14.9. Destroying a jQuery UI Plugin
      1. Problem
      2. Solution
      3. Discussion
    11. 14.10. Creating a jQuery UI Music Player
      1. Problem
      2. Solution
        1. HTML5 audio
        2. The music player
        3. Play and pause button
        4. Current and total time labels
        5. Slider track for song position
        6. Progress bar in track to show buffering
        7. Volume slider
        8. Widget background and top styling
  21. 15. jQuery UI Theming
    1. Introduction
      1. Understanding the Components of jQuery UI CSS
    2. 15.1. Styling jQuery UI Widgets with ThemeRoller
      1. Problem
      2. Solution
        1. Step 1. Open ThemeRoller
        2. Step 2. Create and preview a theme
        3. Step 3. Download the jQuery UI widgets and theme
        4. Step 4. Merge files into your project directory
        5. Step 5. Reference the theme stylesheet in your project
      3. Discussion
    3. 15.2. Overriding jQuery UI Layout and Theme Styles
      1. Problem
      2. Solution
        1. Step 1. Review the widget markup and styles for jQuery UI plugins
        2. Step 2. Create an override stylesheet
        3. Step 3. Edit the style rules in your override stylesheet
          1. Scope overrides
          2. Write override rules
      3. Discussion
    4. 15.3. Applying a Theme to Non-jQuery UI Components
      1. Problem
      2. Solution
        1. Step 1: Review available Framework classes to identify those you can apply to your components
        2. Step 2: Apply clickable-state Framework classes
      3. Discussion
    5. 15.4. Referencing Multiple Themes on a Single Page
      1. Problem
      2. Solution
        1. Step 1. Create another theme using ThemeRoller
        2. Step 2. Scope the new theme and download it
        3. Step 3. Merge files into your project directory
        4. Step 4. Reference the scoped theme stylesheet in your project
    6. 15.5. Appendix: Additional CSS Resources
  22. 16. jQuery, Ajax, Data Formats: HTML, XML, JSON, JSONP
    1. Introduction
    2. 16.1. jQuery and Ajax
      1. Problem
      2. Solution
      3. Discussion
    3. 16.2. Using Ajax on Your Whole Site
      1. Problem
      2. Solution
      3. Discussion
    4. 16.3. Using Simple Ajax with User Feedback
      1. Problem
      2. Solution
      3. Discussion
    5. 16.4. Using Ajax Shortcuts and Data Types
      1. Problem
      2. Solution
      3. Discussion
    6. 16.5. Using HTML Fragments and jQuery
      1. Problem
      2. Solution
      3. Discussion
    7. 16.6. Converting XML to DOM
      1. Problem
      2. Solution
      3. Discussion
    8. 16.7. Creating JSON
      1. Problem
      2. Solution
      3. Discussion
    9. 16.8. Parsing JSON
      1. Problem
      2. Solution
      3. Discussion
    10. 16.9. Using jQuery and JSONP
      1. Problem
      2. Solution
      3. Discussion
  23. 17. Using jQuery in Large Projects
    1. Introduction
    2. 17.1. Using Client-Side Storage
      1. Problem
      2. Solution
      3. Discussion
    3. 17.2. Saving Application State for a Single Session
      1. Problem
      2. Solution
      3. Discussion
    4. 17.3. Saving Application State Between Sessions
      1. Problem
      2. Solution
      3. Discussion
    5. 17.4. Using a JavaScript Template Engine
      1. Problem
      2. Solution
      3. Discussion
    6. 17.5. Queuing Ajax Requests
      1. Problem
      2. Solution
      3. Discussion
    7. 17.6. Dealing with Ajax and the Back Button
      1. Problem
      2. Solution
      3. Discussion
    8. 17.7. Putting JavaScript at the End of a Page
      1. Problem
      2. Solution
      3. Discussion
  24. 18. Unit Testing
    1. Introduction
    2. 18.1. Automating Unit Testing
      1. Problem
      2. Solution
      3. Discussion
    3. 18.2. Asserting Results
      1. Problem
      2. Solution
        1. ok( boolean[, message ])
        2. equals( actual, expected[, message ])
        3. same( actual, expected[, message ])
    4. 18.3. Testing Synchronous Callbacks
      1. Problem
      2. Solution
      3. Discussion
    5. 18.4. Testing Asynchronous Callbacks
      1. Problem
      2. Solution
      3. Discussion
    6. 18.5. Testing User Actions
      1. Problem
      2. Solution
      3. Discussion
    7. 18.6. Keeping Tests Atomic
      1. Problem
      2. Solution
      3. Discussion
    8. 18.7. Grouping Tests
      1. Problem
      2. Solution
      3. Discussion
    9. 18.8. Selecting Tests to Run
      1. Problem
      2. Solution
      3. Discussion
  25. Index
  26. Colophon
  27. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  28. Copyright

Product information

  • Title: jQuery Cookbook
  • Author(s): Cody Lindley
  • Release date: November 2009
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449383015