Synopses & Reviews
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
Synopsis
jQuery has emerged as the most popular Ajax framework, outpacing options such as Dojo and the Prototype JavaScript Framework. With jQuery Cookbook, you'll learn how to add components from the jQuery library to your websites and web applications, with detailed recipes for tasks ranging from basic integration to complex user interface development.
You'll find real-world solutions to common web development hurdles, along with best practices for using jQuery. jQuery Cookbook also includes advanced topics not addressed in existing books that cover this library, such as forms, user interfaces, and methods for applying jQuery to large projects. If you already use jQuery, this book will help you take a step back and rethink your existing jQuery code to make sure it does the job you intend it to do, as efficiently as possible.
If you want to include Ajax as part of your web development process, jQuery is the obvious choice, and jQuery Cookbook is the best way to get the most out of this framework. The jQuery Cookbook team brings together more than a dozen contributors, all of them key people in jQuery's ongoing development process, including:
Cody Lindley Ralph Whitbeck Jonathan Sharp Michael Geary Scott Gonzalez Rebecca Murphey Remy Sharp Ariel Flesler Brian Cherne Jorn Zaefferer Mike Hostetler Nathan Smith Filament Group Jonathan Sharp Mike Hostetler James Padolsey Richard Worth
Synopsis
This book provides concrete details on how to build web interfaces with jQuery, the champion of the Ajax frameworks. jQuery rapidly climbed to prominence in the Ajax world, leaping forward in a crowded field. While much of that has to do with its power and relative ease of use, applying jQuery is still a challenge. "jQuery Cookbook" shows readers how to add jQuery to their web sites and applications, with recipe after recipe detailing tasks from basic integration to complex user interface development.
Synopsis
"As someone who uses jQuery on a regular basis, it was surprising to discover how much of the library Im not using. This book is indispensable for anyone who is serious about using jQuery for non-trivial applications." -- Raffaele Cecco, longtime developer of video games, including Cybernoid, Exolon, and Stormlord
jQuery is the "write less, do more" JavaScript library. Its powerful features and ease of use have made it the most popular client-side JavaScript framework for the Web. This book is jQuery's trusty companion: the definitive "read less, learn more" guide to the library.
jQuery Pocket Reference explains everything you need to know about jQuery, completely and comprehensively. You'll learn how to:
- Select and manipulate document elements
- Alter document structure
- Handle and trigger events
- Create visual effects and animations
- Script HTTP with Ajax utilities
- Use jQuery's selectors and selection methods, utilities, plugins and more
The 25-page quick reference summarizes the library, listing all jQuery methods and functions, with signatures and descriptions.
Synopsis
The Canvas element is a revolutionary feature of HTML5 that enables powerful graphics for rich Internet applications, and this pocket reference provides the essentials you need to put this element to work. If you have working knowledge of JavaScript, this book will help you create detailed, interactive, and animated graphics -- from charts to animations to video games -- whether you're a web designer or a programmer interested in graphics.
Canvas Pocket Reference provides both a tutorial that covers all of the element's features with plenty of examples and a definitive reference to each of the Canvas-related classes, methods, and properties.
You'll learn how to:
- Draw lines, polygons, and curves
- Apply colors, gradients, patterns, and transparency
- Use transformations to smoothly rotate and resize drawings
- Work with text in a graphic environment
- Apply shadows to create a sense of depth
- Incorporate bitmapped images into vector graphics
- Perform image processing operations in JavaScript
About the Author
David Flanagan is a computer programmer who spends most of his time writing about JavaScript and Java. His books with O'Reilly include JavaScript: The Definitive Guide, JavaScript Pocket Reference, Java in a Nutshell, Java Examples in a Nutshell, and Java Foundation Classes in a Nutshell. David has a blog at www.davidflanagan.com.
Table of Contents
Foreword; Contributors; Chapter Authors; Tech Editors; Preface; Who This Book Is For; What You'll Learn; jQuery Style and Conventions; Other Options; If You Have Problems Making Examples Work; If You Like (or Don't Like) This Book; Conventions Used in This Book; Using Code Examples; Safari® Books Online; How to Contact Us; Chapter 1: jQuery Basics; 1.1 Introduction; 1.2 Including the jQuery Library Code in an HTML Page; 1.3 Executing jQuery/JavaScript Coded After the DOM Has Loaded but Before Complete Page Load; 1.4 Selecting DOM Elements Using Selectors and the jQuery Function; 1.5 Selecting DOM Elements Within a Specified Context; 1.6 Filtering a Wrapper Set of DOM Elements; 1.7 Finding Descendant Elements Within the Currently Selected Wrapper Set; 1.8 Returning to the Prior Selection Before a Destructive Change; 1.9 Including the Previous Selection with the Current Selection; 1.10 Traversing the DOM Based on Your Current Context to Acquire a New Set of DOM Elements; 1.11 Creating, Operating on, and Inserting DOM Elements; 1.12 Removing DOM Elements; 1.13 Replacing DOM Elements; 1.14 Cloning DOM Elements; 1.15 Getting, Setting, and Removing DOM Element Attributes; 1.16 Getting and Setting HTML Content; 1.17 Getting and Setting Text Content; 1.18 Using the $ Alias Without Creating Global Conflicts; Chapter 2: Selecting Elements with jQuery; 2.1 Introduction; 2.2 Selecting Child Elements Only; 2.3 Selecting Specific Siblings; 2.4 Selecting Elements by Index Order; 2.5 Selecting Elements That Are Currently Animating; 2.6 Selecting Elements Based on What They Contain; 2.7 Selecting Elements by What They Don't Match; 2.8 Selecting Elements Based on Their Visibility; 2.9 Selecting Elements Based on Attributes; 2.10 Selecting Form Elements by Type; 2.11 Selecting an Element with Specific Characteristics; 2.12 Using the Context Parameter; 2.13 Creating a Custom Filter Selector; Chapter 3: Beyond the Basics; 3.1 Introduction; 3.2 Looping Through a Set of Selected Results; 3.3 Reducing the Selection Set to a Specified Item; 3.4 Convert a Selected jQuery Object into a Raw DOM Object; 3.5 Getting the Index of an Item in a Selection; 3.6 Making a Unique Array of Values from an Existing Array; 3.7 Performing an Action on a Subset of the Selected Set; 3.8 Configuring jQuery Not to Conflict with Other Libraries; 3.9 Adding Functionality with Plugins; 3.10 Determining the Exact Query That Was Used; Chapter 4: jQuery Utilities; 4.1 Introduction; 4.2 Detecting Features with jQuery.support; 4.3 Iterating Over Arrays and Objects with jQuery.each; 4.4 Filtering Arrays with jQuery.grep; 4.5 Iterating and Modifying Array Entries with jQuery.map; 4.6 Combining Two Arrays with jQuery.merge; 4.7 Filtering Out Duplicate Array Entries with jQuery.unique; 4.8 Testing Callback Functions with jQuery.isFunction; 4.9 Removing Whitespace from Strings or Form Values with jQuery.trim; 4.10 Attaching Objects and Data to DOM with jQuery.data; 4.11 Extending Objects with jQuery.extend; Chapter 5: Faster, Simpler, More Fun; 5.1 Introduction; 5.2 That's Not jQuery, It's JavaScript!; 5.3 What's Wrong with $(this)?; 5.4 Removing Redundant Repetition; 5.5 Formatting Your jQuery Chains; 5.6 Borrowing Code from Other Libraries; 5.7 Writing a Custom Iterator; 5.8 Toggling an Attribute; 5.9 Finding the Bottlenecks; 5.10 Caching Your jQuery Objects; 5.11 Writing Faster Selectors; 5.12 Loading Tables Faster; 5.13 Coding Bare-Metal Loops; 5.14 Reducing Name Lookups; 5.15 Updating the DOM Faster with .innerHTML; 5.16 Debugging? Break Those Chains; 5.17 Is It a jQuery Bug?; 5.18 Tracing into jQuery; 5.19 Making Fewer Server Requests; 5.20 Writing Unobtrusive JavaScript; 5.21 Using jQuery for Progressive Enhancement; 5.22 Making Your Pages Accessible; Chapter 6: Dimensions; 6.1 Introduction; 6.2 Finding the Dimensions of the Window and Document; 6.3 Finding the Dimensions of an Element; 6.4 Finding the Offset of an Element; 6.5 Scrolling an Element into View; 6.6 Determining Whether an Element Is Within the Viewport; 6.7 Centering an Element Within the Viewport; 6.8 Absolutely Positioning an Element at Its Current Position; 6.9 Positioning an Element Relative to Another Element; 6.10 Switching Stylesheets Based on Browser Width; Chapter 7: Effects; 7.1 Introduction; 7.2 Sliding and Fading Elements in and out of View; 7.3 Making Elements Visible by Sliding Them Up; 7.4 Creating a Horizontal Accordion; 7.5 Simultaneously Sliding and Fading Elements; 7.6 Applying Sequential Effects; 7.7 Determining Whether Elements Are Currently Being Animated; 7.8 Stopping and Resetting Animations; 7.9 Using Custom Easing Methods for Effects; 7.10 Disabling All Effects; 7.11 Using jQuery UI for Advanced Effects; Chapter 8: Events; 8.1 Introduction; 8.2 Attaching a Handler to Many Events; 8.3 Reusing a Handler Function with Different Data; 8.4 Removing a Whole Set of Event Handlers; 8.5 Triggering Specific Event Handlers; 8.6 Passing Dynamic Data to Event Handlers; 8.7 Accessing an Element ASAP (Before document.ready); 8.8 Stopping the Handler Execution Loop; 8.9 Getting the Correct Element When Using event.target; 8.10 Avoid Multiple hover() Animations in Parallel; 8.11 Making Event Handlers Work for Newly Added Elements; Chapter 9: Advanced Events; 9.1 Introduction; 9.2 Getting jQuery to Work When Loaded Dynamically; 9.3 Speeding Up Global Event Triggering; 9.4 Creating Your Own Events; 9.5 Letting Event Handlers Provide Needed Data; 9.6 Creating Event-Driven Plugins; 9.7 Getting Notified When jQuery Methods Are Called; 9.8 Using Objects' Methods as Event Listeners; Chapter 10: HTML Form Enhancements from Scratch; 10.1 Introduction; 10.2 Focusing a Text Input on Page Load; 10.3 Disabling and Enabling Form Elements; 10.4 Selecting Radio Buttons Automatically; 10.5 (De)selecting All Checkboxes Using Dedicated Links; 10.6 (De)selecting All Checkboxes Using a Single Toggle; 10.7 Adding and Removing Select Options; 10.8 Autotabbing Based on Character Count; 10.9 Displaying Remaining Character Count; 10.10 Constraining Text Input to Specific Characters; 10.11 Submitting a Form Using Ajax; 10.12 Validating Forms; Chapter 11: HTML Form Enhancements with Plugins; 11.1 Introduction; 11.2 Validating Forms; 11.3 Creating Masked Input Fields; 11.4 Autocompleting Text Fields; 11.5 Selecting a Range of Values; 11.6 Entering a Range-Constrained Value; 11.7 Uploading Files in the Background; 11.8 Limiting the Length of Text Inputs; 11.9 Displaying Labels Above Input Fields; 11.10 Growing an Input with Its Content; 11.11 Choosing a Date; Chapter 12: jQuery Plugins; 12.1 Introduction; 12.2 Where Do You Find jQuery Plugins?; 12.3 When Should You Write a jQuery Plugin?; 12.4 Writing Your First jQuery Plugin; 12.5 Passing Options into Your Plugin; 12.6 Using the $ Shortcut in Your Plugin; 12.7 Including Private Functions in Your Plugin; 12.8 Supporting the Metadata Plugin; 12.9 Adding a Static Function to Your Plugin; 12.10 Unit Testing Your Plugin with QUnit; Chapter 13: Interface Components from Scratch; 13.1 Introduction; 13.2 Creating Custom Tool Tips; 13.3 Navigating with a File-Tree Expander; 13.4 Expanding an Accordion; 13.5 Tabbing Through a Document; 13.6 Displaying a Simple Modal Window; 13.7 Building Drop-Down Menus; 13.8 Cross-Fading Rotating Images; 13.9 Sliding Panels; Chapter 14: User Interfaces with jQuery UI; 14.1 Introduction; 14.2 Including the Entire jQuery UI Suite; 14.3 Including an Individual jQuery UI Plugin or Two; 14.4 Initializing a jQuery UI Plugin with Default Options; 14.5 Initializing a jQuery UI Plugin with Custom Options; 14.6 Creating Your Very Own jQuery UI Plugin Defaults; 14.7 Getting and Setting jQuery UI Plugin Options; 14.8 Calling jQuery UI Plugin Methods; 14.9 Handling jQuery UI Plugin Events; 14.10 Destroying a jQuery UI Plugin; 14.11 Creating a jQuery UI Music Player; Chapter 15: jQuery UI Theming; 15.1 Introduction; 15.2 Styling jQuery UI Widgets with ThemeRoller; 15.3 Overriding jQuery UI Layout and Theme Styles; 15.4 Applying a Theme to Non-jQuery UI Components; 15.5 Referencing Multiple Themes on a Single Page; 15.6 Appendix: Additional CSS Resources; Chapter 16: jQuery, Ajax, Data Formats: HTML, XML, JSON, JSONP; 16.1 Introduction; 16.2 jQuery and Ajax; 16.3 Using Ajax on Your Whole Site; 16.4 Using Simple Ajax with User Feedback; 16.5 Using Ajax Shortcuts and Data Types; 16.6 Using HTML Fragments and jQuery; 16.7 Converting XML to DOM; 16.8 Creating JSON; 16.9 Parsing JSON; 16.10 Using jQuery and JSONP; Chapter 17: Using jQuery in Large Projects; 17.1 Introduction; 17.2 Using Client-Side Storage; 17.3 Saving Application State for a Single Session; 17.4 Saving Application State Between Sessions; 17.5 Using a JavaScript Template Engine; 17.6 Queuing Ajax Requests; 17.7 Dealing with Ajax and the Back Button; 17.8 Putting JavaScript at the End of a Page; Chapter 18: Unit Testing; 18.1 Introduction; 18.2 Automating Unit Testing; 18.3 Asserting Results; 18.4 Testing Synchronous Callbacks; 18.5 Testing Asynchronous Callbacks; 18.6 Testing User Actions; 18.7 Keeping Tests Atomic; 18.8 Grouping Tests; 18.9 Selecting Tests to Run; Colophon;