Book Reviews - Pro jQuery 2.0

Book Reviews - Pro jQuery 2.0
jQuery 2.0 is the latest version of the jQuery framework. Suitable for modern web browsers it provides a robust API for web application development. It is fast becoming the tool of choice for web developers the world over and sets the standard for simplicity,flexibility and extensibility in website design.
In Pro jQuery 2.0 seasoned author, Adam Freeman, demonstrates how to get the most from jQuery 2.0 by focussing on the practical features of the technology and how they can be applied to solving real-world problems. In this comprehensive reference he goes in depth to give you the practical knowledge that you need.
Each topic is covered clearly and concisely, and is packed with the details you'll need to learn to be truly effective. The most important features are given a no-nonsense, in-depth treatment, and chapters contain examples that demonstrate both the power and the subtlety of jQuery.
Chapter 1: Putting jQuery in Context .....................................1
Understanding jQuery UI and jQuery Mobile ............................................1
Understanding jQuery Plug-ins ...........................................1
What Do I Need to Know? ............................................................2
What Is the Structure of This Book? .............................................2
Part 1: Getting Ready .........................................................................2
Part 2: Working with jQuery .......................................................... 2
Part 3: Working with Data and Ajax ............................................... 2
Part 4: Using jQuery UI ...............................................2
Part 5: Using jQuery Mobile ............................................................ 2
Part 6: Advanced Features 

 What’s New in This Edition? ..........................................3
What’s New for Core jQuery? ....................................................... 3
What’s New for jQuery UI? ........................................................ 3
What’s New for jQuery Mobile? ....................................................... 3
What Else Is New? ...................................................................................4
Are There Lots of Examples? 4
Where Can I Get the Example Code? 6
What Software Do I Need for This Book? ......................................................................................6
Getting jQuery 6
Getting an HTML Editor ..........................................................................................................................................7
Getting a Web Browser ..........................................................................................................................................7
Getting a Web Server .............................................................................................................................................7
Getting Node.js......................................................................................................................................................8
Image Attribution ...........................................................................................................................9
Chapter 2: HTML Primer ..................................................................................................11
Introducing a Basic HTML Document ..........................................................................................11
Understanding the Anatomy of an HTML Element .......................................................................13
Understanding Attributes ......................................................................14
The id and class Attributes ............................................................................. 14
Understanding Element Content ..................................................................................................15
Understanding Void Elements .....................................................................................................16
Understanding the Document Structure .................................................16
Understanding the Metadata Elements .......................................................................... 17
Understanding the Content Elements ........................................................................ 19
Understanding the Element Hierarchy .........................................................................................24
Understanding Parent-Child Relationships ........................................................................... 24
Understanding Ancestor-Descendant Relationships ............................................... 25
Understanding Sibling Relationships ............................................................ 25
Understanding the Document Object Model ...........................................25
Using the DOM .................................................................26
Modifying the DOM ....................................................................28
Modifying Styles .....................................................................................29
Handling Events ....................................................................................30
Chapter 3: CSS Primer ........................................................33
Getting Started with CSS ...............................................................33
Setting an Inline Value ..........................................................35
Defining an Embedded Style ....................................................36
Defining an External Style Sheet .................................39
Understanding CSS Selectors .........................40
Selecting by Attribute .....................................................................41
Selecting by Relationship ..................................................................... 42
Selecting Using the Pseudo-element and Pseudo-class Selectors ................................................ 44
Unions and the Negation Selectors .............................................................................. 46
Understanding Style Cascading .......................................................47
Understanding How Styles Cascade ................................................................... 48
Tweaking the Order with Important Styles ................................................................. 49
Tie-Breaking with Specificity and Order Assessments ......................................................... 50
Understanding CSS Units ............................................................................................................52
Working with CSS Colors ...................................................................... 53
Understanding CSS Lengths ................................................................................................ 54
Using Shorthand Properties and Custom Values .........................................................................58
Chapter 4: JavaScript Primer ..........................................................................................61
Getting Ready to Use JavaScript .................................................................................................61
Using Statements ........................................................................................................................62
Defining and Using Functions .....................................................................................................63
Defining Functions with Parameters ................................................................ 64
Defining Functions That Return Results ........................................................... 65
Using Variables and Types ..........................................................................66
Using the Primitive Types ................................................................ 66
Creating Objects .......................................................68
Working with Objects
Using JavaScript Operators ..........................................................75
Using Conditional Statements ................................................................................. 75
The Equality Operator vs. the Identity Operator .................................................................. 76
Explicitly Converting Types ........................................................................ 79
Working with Arrays ....................................................................................................................82
Using an Array Literal ..........................................................................................................................................82
Reading and Modifying the Contents of an Array ................................................................................................ 83
Enumerating the Contents of an Array ................................................................................................................. 84
Using the Built-in Array Methods ......................................................................................................................... 85
Handling Errors ...........................................................................................................................85
Comparing undefined and null Values .........................................................................................87
Checking for null or undefined ............................................................................................................................ 89
Differentiating Between null and undefined ........................................................................................................ 90
Chapter 5: jQuery Basics .................................................................................................93
Setting Up jQuery ........................................................................................................................94
Using Conditional Comments ............................................................................................................................... 96
A First jQuery Script ....................................................................................................................97
Understanding the jQuery $ Function ..........................................................................................99
Waiting for the Document Object Model ...................................................................................101
Using the Alternative Notation ........................................................................................................................... 102
Deferring the ready Event .................................................................................................................................. 103
Selecting Elements ....................................................................................................................104
Narrowing the Selection with a Context ............................................................................................................ 106
Understanding the Selection Result ..........................................................................................107
Determining the Context ....................................................................................................................................108
Dealing with DOM Objects ................................................................................................................................. 109
Modifying Multiple Elements and Chaining Method Calls .........................................................113
Handling Events ........................................................................................................................116
Chapter 7: Manipulating the DOM .................................................................................145
Creating New Elements .............................................................................................................146
Creating Elements Using the $ Function ........................................................................................................... 146
Creating New Elements by Cloning Existing Elements ...................................................................................... 148
Creating Elements Using the DOM API ............................................................................................................... 149
Inserting Child and Descendant Elements ................................................................................150
Prepending Elements .........................................................................................................................................152
Inserting the Same Elements in Different Positions .......................................................................................... 154
Inserting from a jQuery Object ........................................................................................................................... 156
Inserting Elements Using a Function ................................................................................................................. 157
Inserting Parent and Ancestor Elements ...................................................................................159
Wrapping Elements Together in a Single Parent ................................................................................................ 161
Wrapping the Content of Elements .................................................................................................................... 163
Wrapping Elements Using a Function
Inserting Sibling Elements ........................................................................................................166
Inserting Siblings from a jQuery Object ............................................................................................................. 167
Inserting Siblings Using a Function ................................................................................................................... 168
Replacing Elements ...................................................................................................................169
Replacing Elements Using a Function ............................................................................................................... 170
Removing Elements ...................................................................................................................172
Detaching Elements ...........................................................................................................................................173
Empting Elements ..............................................................................................................................................174
Unwrapping Elements .......................................................................................................................................175
Chapter 8: Manipulating Elements ................................................................................177
Working with Attributes and Properties ....................................................................................178
Setting an Attribute Value .................................................................................................................................. 180
Setting Multiple Attributes ................................................................................................................................. 181
Setting Attribute Values Dynamically ................................................................................................................. 183
Removing an Attribute .......................................................................................................................................184
Working with Properties ....................................................................................................................................184
Working with Classes ................................................................................................................185
Adding and Removing Classes Using a Function ............................................................................................... 187
Toggling Classes ................................................................................................................................................189
Toggling Multiple Classes .................................................................................................................................. 192
Toggling All Classes ...........................................................................................................................................193
Toggling Classes in One Direction ..................................................................................................................... 194
Toggling Classes Dynamically ........................................................................................................................... 195
Working with CSS ......................................................................................................................196
Getting and Setting a Single CSS Value ............................................................................................................. 197
Getting Multiple CSS Properties ........................................................................................................................ 198
Setting Multiple CSS Properties ....................................................................................................................... 198
Setting Relative Values ......................................................................................................................................200
Setting Properties Using a Function .................................................................................................................. 200
Using the Property-Specific CSS Convenience Methods ................................................................................... 201
Working with Element Content ..................................................................................................203
Setting Element Content ....................................................................................................................................204
Setting Element Content Using a Function ........................................................................................................ 205
Working with Form Elements ....................................................................................................206
Setting Form Element Values ............................................................................................................................ 207
Setting Form Element Values Using a Function ................................................................................................. 208
Associating Data with Elements ................................................................................................209
Chapter 9: Working with Events ....................................................................................211
Handling Events ........................................................................................................................212
Registering a Function to Handle Multiple Event Types ..................................................................................... 215
Providing Data to the Event Handler Function ................................................................................................... 216
Suppressing the Default Action ......................................................................................................................... 217
Removing Event Handler Functions ................................................................................................................... 218
Executing a Handler Once ................................................................................................................................. 220
Performing Live Event Binding ..................................................................................................221
Limiting DOM Traversal for Live Event Handlers ................................................................................................ 224
Manually Invoking Event Handlers ............................................................................................225
Using an Event Object ........................................................................................................................................227
Using the triggerHandler Method ...................................................................................................................... 228
Using the Event Shorthand Methods .........................................................................................229
Using the Document Event Shorthand Methods ................................................................................................ 231
Using the Browser Event Shorthand Methods ................................................................................................... 231
Using the Mouse Event Shorthand Methods ...................................................................................................... 231
Using the Form Event Shorthand Methods ........................................................................................................ 233
Using the Keyboard Event Shorthand Methods ................................................................................................. 233
Chapter 10: Using jQuery Effects ...................................................................................235
Using the Basic Effects .............................................................................................................236
Toggling Elements .............................................................................................................................................239
Toggling in One Direction ...................................................................................................................................240
Animating the Visibility of Elements .................................................................................................................. 240
Using Effect Callbacks .......................................................................................................................................242
Creating Looping Effects ...................................................................................................................................245
Using the Slide Effects ..............................................................................................................247
Using the Fade Effects ..............................................................................................................248
Fading to a Specific Opacity .............................................................................................................................. 250
Creating Custom Effects ............................................................................................................252
Using Absolute Target Property Values .............................................................................................................. 254
Using Relative Target Property Values ............................................................................................................... 255
Creating and Managing the Effect Queue ..................................................................................256
Displaying the Items in the Effect Queue .......................................................................................................... 257
Stopping Effects and Clearing the Queue .......................................................................................................... 259
Inserting a Delay into the Queue ....................................................................................................................... 262
Inserting Functions into the Queue .................................................................................................................... 263
Enabling and Disabling Effect Animations .................................................................................264
Chapter 11: Refactoring the Example: Part I .................................................................267
Reviewing the Example Document ............................................................................................267
Adding Additional Flower Products ...........................................................................................269
Adding the Carousel Buttons .....................................................................................................271
Dealing with the Submit Button ................................................................................................273
Implementing the Carousel Event Handler Functions ...............................................................275
Totaling the Product Selection ..................................................................................................278
Disabling JavaScript ..................................................................................................................280
Chapter 12: Using Data Templates .................................................................................281
Understanding the Problem That Templates Solve ....................................................................282
Setting Up the Template Library ................................................................................................283
A First Data Templates Example ................................................................................................284
Defining the Data ...............................................................................................................................................286
Defining the Template ........................................................................................................................................286
Applying the Template .......................................................................................................................................287
Using Template Logic ................................................................................................................291
Creating Conditional Content ............................................................................................................................. 291
Enumerating Arrays and Properties ................................................................................................................... 294
Changing the Data Context ................................................................................................................................ 296
Creating Custom Template Helpers ...........................................................................................300
Creating a Conditional Template Helper ............................................................................................................ 301
Returning More Complex Content ...................................................................................................................... 304
Receiving Optional Arguments in the Helper Function ...................................................................................... 305
Providing Custom Template Properties .............................................................................................................. 307
Chapter 13: Working with Forms ...................................................................................309
Preparing the Node.js Server ....................................................................................................310
Recapping the Form-Event Methods .........................................................................................314
Dealing with Form Focus ...................................................................................................................................314
Dealing with Value Changes .............................................................................................................................. 316
Dealing with Form Submission .......................................................................................................................... 317
Validating Form Values ..............................................................................................................319
Using the Validation Checks ............................................................................................................................. 324
Specifying Validation Messages ........................................................................................................................ 334
Creating a Custom Check .................................................................................................................................. 339
Formatting the Validation Error Display ............................................................................................................. 342
Using a Validation Summary .............................................................................................................................. 345
Chapter 14: Using Ajax: Part I .......................................................................................351
Using the Ajax Shorthand Methods ...........................................................................................352
Performing an Ajax GET Request ....................................................................................................................... 352
Performing an Ajax POST Request ..................................................................................................................... 360
Specifying the Expected Data Type .................................................................................................................... 368
Avoiding the Most Common Ajax Pitfall .....................................................................................369
Using the Type-Specific Convenience Methods ........................................................................371
Getting an HTML Fragment ................................................................................................................................ 371
Getting and Executing Scripts ........................................................................................................................... 374
Getting JSON Data .............................................................................................................................................376
Using the Ajax Forms Plug-in ....................................................................................................378
Chapter 15: Using Ajax: Part II ......................................................................................381
Making a Simple Ajax Request with the Low-Level API ............................................................382
Understanding the jqXHR Object ...............................................................................................384
Setting the Request URL ...........................................................................................................385
Making a POST Request ............................................................................................................386
Handling Ajax Callbacks ............................................................................................................387
Dealing with Successful Requests .................................................................................................................... 388
Dealing with Errors ............................................................................................................................................389
Dealing with Completed Requests ..................................................................................................................... 390
Configuring Requests Before They Are Sent ...................................................................................................... 392
Specifying Multiple Event Handler Functions .................................................................................................... 393
Setting the Context for Events ........................................................................................................................... 393
Using the Global Ajax Events .....................................................................................................394
Controlling Global Events ...................................................................................................................................397
Configuring the Basic Settings for an Ajax Request ..................................................................398
Setting Timeouts and Headers ........................................................................................................................... 398
Sending JSON Data to the Server
Using Advanced Configuration Settings ....................................................................................401
Making the Request Synchronously .................................................................................................................. 401
Ignoring Unmodified Data .................................................................................................................................. 402
Dealing with the Response Status Code ............................................................................................................ 403
Cleaning Up the Response Data ........................................................................................................................ 405
Managing Data Conversion ................................................................................................................................ 406
Setting Up and Filtering Ajax Requests .....................................................................................407
Defining Default Settings ...................................................................................................................................407
Filtering Requests ..............................................................................................................................................408
Chapter 16: Refactoring the Example: Part II ................................................................411
Reviewing the Refactored Example ..........................................................................................411
Updating the Node.js Script .......................................................................................................414
Preparing for Ajax ......................................................................................................................416
Sourcing the Product Information .............................................................................................419
Adding Form Validation .............................................................................................................422
Adding Remote Validation .................................................................................................................................. 426
Submitting the Form Data Using Ajax .......................................................................................428
Processing the Server Response ..............................................................................................436
Adding the New Form ........................................................................................................................................442
Completing the Ajax Request ............................................................................................................................. 443
Processing the Data ..........................................................................................................................................445
Chapter 17: Setting Up jQuery UI ...................................................................................449
Obtaining jQuery UI ...................................................................................................................449
Deciding on a Theme .........................................................................................................................................449
Creating the jQuery UI Custom Download .......................................................................................................... 451
Installing jQuery UI for Development .........................................................................................452
Adding jQuery UI to an HTML Document
Installing jQuery UI for Production .............................................................................................454
Using jQuery UI via a Content Distribution Network .......................................................................................... 454
Chapter 18: Using the Button, Progress Bar, and Slider Widgets ..................................457
Using the jQuery UI Button ........................................................................................................458
Configuring the Button ......................................................................................................................................460
Using jQuery UI Icons in Buttons ....................................................................................................................... 462
Using a Custom Image .......................................................................................................................................464
Using the Button Methods ................................................................................................................................. 465
Using the Button Event ......................................................................................................................................468
Creating Different Types of Button ............................................................................................469
Creating a Toggle Button ...................................................................................................................................470
Creating a Button Set ........................................................................................................................................471
Using the jQuery UI Progress Bar ..............................................................................................473
Creating the Progress Bar ................................................................................................................................. 474
Creating an Indeterminate Progress Bar ........................................................................................................... 475
Using the Progress Bar Methods ....................................................................................................................... 476
Using the Progress Bar Events .......................................................................................................................... 478
Using the jQuery UI Slider .........................................................................................................480
Configuring the Slider ........................................................................................................................................481
Using the Slider Methods .................................................................................................................................. 486
Using Slider Events ............................................................................................................................................488
Chapter 19: Using the Autocomplete and Accordion Widgets .......................................491
Using jQuery UI Autocomplete ...................................................................................................492
Creating the Autocomplete Element .................................................................................................................. 492
Configuring Autocomplete ................................................................................................................................. 495
Using the Autocomplete Methods ...................................................................................................................... 503
Using the Autocomplete Events
Using the jQuery UI Accordion ...................................................................................................510
Creating the Accordion ......................................................................................................................................510
Configuring the Accordion ................................................................................................................................ 514
Using the Accordion Methods ............................................................................................................................ 524
Using the Accordion Events ............................................................................................................................... 525
Chapter 20: Using the Tabs Widget ................................................................................527
Creating the Tabs .......................................................................................................................528
Getting Tab Content with Ajax ...................................................................................................531
Configuring the Tabs Widget ......................................................................................................533
Selecting the Active Tab ....................................................................................................................................533
Disabling Individual Tabs ...................................................................................................................................535
Changing the Event Trigger ................................................................................................................................ 537
Using Collapsible Tabs .......................................................................................................................................538
Using the Tabs Methods ............................................................................................................539
Adding and Removing Tabs ............................................................................................................................... 539
Triggering Tab Ajax Requests ............................................................................................................................. 541
Using the Tabs Events ...............................................................................................................542
Intercepting Ajax Requests ................................................................................................................................ 543
Manipulating Remote Tab Data .......................................................................................................................... 544
Using Tabs to Display a Form ............................................................................................................................ 545
Chapter 21: Using the Datepicker Widget ......................................................................555
Creating the Datepicker ............................................................................................................556
Creating an Inline Datepicker ............................................................................................................................ 557
Configuring the Datepicker ......................................................................................................559
Performing Basic Configuration ......................................................................................................................... 559
Managing the Date Selection ............................................................................................................................ 565
Managing the Appearance of the Datepicker
Using the Datepicker Methods ..................................................................................................578
Getting and Setting the Date Programmatically ................................................................................................ 578
Showing and Hiding Pop-up Datepickers Programmatically ............................................................................ 580
Using the Datepicker Events .....................................................................................................581
Responding to a Month or Year Change ............................................................................................................ 582
Responding to the Pop-up Closing .................................................................................................................... 583
Localizing Date Selection ..........................................................................................................584
Chapter 22: Using the Dialog and Spinner Widgets .......................................................587
Using the jQuery UI Dialog Widget .............................................................................................588
Creating the Dialog ............................................................................................................................................588
Configuring the Dialog .......................................................................................................................................590
Using the Dialog Methods .................................................................................................................................. 602
Using the Dialog Events .....................................................................................................................................604
Using the jQuery UI Spinner Widget ..........................................................................................607
Using the Spinner Widget with the HTML5 Input Element Types ....................................................................... 608
Configuring the Spinner Widget ........................................................................................................................ 611
Using the Spinner Methods ............................................................................................................................... 617
Using the Spinner Events ..................................................................................................................................619
Chapter 23: Using the Menu and Tooltip Widgets ..........................................................621
Using the jQuery UI Menu Widget ..............................................................................................622
Creating the Menu ............................................................................................................................................622
Configuring the Menu ........................................................................................................................................625
Using the Menu Methods ...................................................................................................................................631
Using the Menu Events ......................................................................................................................................632
Using the jQuery UI Tooltip Widget ...........................................................................................634
Creating the Tooltip ............................................................................................................................................635
Configuring the Tooltip
Using the Tooltip Methods ................................................................................................................................. 647
Using the Tooltip Events ....................................................................................................................................649
Chapter 24: Using the Drag-and-Drop Interactions .......................................................653
Creating the Draggable Interaction ...........................................................................................654
Configuring the Draggable Interaction ............................................................................................................... 655
Using the Draggable Methods ........................................................................................................................... 661
Using the Draggable Events .............................................................................................................................. 662
Using the Droppable Interaction ................................................................................................663
Highlighting a Drop Target ................................................................................................................................. 665
Dealing with Overlapping Elements ................................................................................................................... 667
Configuring the Droppable Interaction ............................................................................................................... 668
Using the Droppable Methods ........................................................................................................................... 674
Tuning Drag and Drop ................................................................................................................674
Using Element Scope .........................................................................................................................................674
Using a Helper Element .....................................................................................................................................676
Snapping to the Edges of Elements ................................................................................................................... 680
Chapter 25: Using the Other Interactions ......................................................................683
Using the Sortable Interaction ...................................................................................................684
Getting the Sortable Order ................................................................................................................................. 685
Configuring the Sortable Interaction .................................................................................................................. 687
Using the Sortable Methods .............................................................................................................................. 693
Using the Sortable Events ................................................................................................................................. 695
Using the Selectable Interaction ...............................................................................................697
Configuring the Selectable Interaction .............................................................................................................. 699
Using the Selectable Interaction Methods ......................................................................................................... 700
Using the Selectable Interaction Events ............................................................................................................ 701
Using the Resizable Interaction .................................................................................................701
Configuring the Resizable Interaction ................................................................................................................ 703
Chapter 26: Refactoring the Example: Part III ...............................................................709
Reviewing the Refactored Example ..........................................................................................709
Displaying the Products ............................................................................................................711
Adding the Shopping Basket .....................................................................................................713
Wrapping the Accordion ....................................................................................................................................715
Adding the Table ................................................................................................................................................715
Handling Input Value Changes ........................................................................................................................... 716
Applying the Theme Style .........................................................................................................720
Applying the CSS Framework More Widely ....................................................................................................... 721
Applying Rounded Corners to the Table ............................................................................................................. 722
Creating the jQuery UI Button ....................................................................................................725
Adding the Completion Dialog ...................................................................................................728
Handling the Place Order Button Click ......................................................................................731
Completing the Order ................................................................................................................734
Chapter 27: Getting Started with jQuery Mobile ............................................................737
Setting Up jQuery Mobile ..........................................................................................................737
Obtaining jQuery Mobile ....................................................................................................................................738
Installing jQuery Mobile ....................................................................................................................................738
Understanding the jQuery Mobile Approach ..............................................................................739
Understanding Automatic Enhancement ........................................................................................................... 740
Understanding the Viewport ............................................................................................................................. 742
Understanding jQuery Mobile Events ................................................................................................................. 744
Responding to Device Orientation Changes ...................................................................................................... 754
Working with Mobile Devices ....................................................................................................756
Avoiding the Two Cardinal Sins of Mobile Development .................................................................................... 757
Avoiding Bad Assumptions ................................................................................................................................ 757
Avoiding Unrealistic Simulation and Testing ...................................................................................................... 759
Using a Mobile Browser Emulator ..................................................................................................................... 761
Chapter 28: Pages, Themes & Layouts ..........................................................................763
Understanding jQuery Mobile Pages .........................................................................................764
Adding Headers and Footers to a Page ............................................................................................................. 765
Adding Pages to a Document ............................................................................................................................ 766
Linking to External Pages .................................................................................................................................. 771
Using Scripting to Control jQuery Mobile Pages ........................................................................778
Changing the Current Page ................................................................................................................................ 778
Determining the Current Page ........................................................................................................................... 784
Loading Pages in the Background ..................................................................................................................... 786
Using Page Events .....................................................................................................................787
Handling the Page Initialization Event ............................................................................................................... 788
Handling Page Load Events ............................................................................................................................... 788
Responding to Page Transitions ........................................................................................................................ 789
Applying jQuery Mobile Themes ................................................................................................790
Applying Swatches to Individual Elements ........................................................................................................ 793
Creating Grid Layouts ................................................................................................................794
Chapter 29: The Dialog & Popup Widgets ......................................................................797
Using the jQuery Mobile Dialog Widget .....................................................................................798
Creating the Dialog Widget ................................................................................................................................ 798
Configuring the Dialog Widget ........................................................................................................................... 804
Using the Dialog Methods .................................................................................................................................. 808
Using the Dialog Events .....................................................................................................................................809
Using the jQuery Mobile Popup Widget .....................................................................................810
Creating the Popup Widget ................................................................................................................................ 810
Configuring the Popup Widget ........................................................................................................................... 811
Using the Popup Methods .................................................................................................................................. 818
Using the Popup Events .....................................................................................................................................820
Chapter 30: Buttons and Collapsible Blocks .................................................................823
Using jQuery Mobile Buttons .....................................................................................................824
Creating the Button Widget ................................................................................................................................ 824
Configuring jQuery Mobile Buttons .................................................................................................................... 828
Using the Button Methods ................................................................................................................................. 832
Using the Button Events ....................................................................................................................................834
Using jQuery Mobile NavBars ....................................................................................................835
Configuring jQuery Mobile NavBar .................................................................................................................... 837
Using the NavBar Methods & Events ................................................................................................................. 838
Using Collapsible Content Blocks ..............................................................................................838
Creating the Collapsible Block ........................................................................................................................... 838
Configuring jQuery Mobile Collapsible Content Blocks ...................................................................................... 839
Using Collapsible Block Methods ...................................................................................................................... 841
Using Collapsible Block Events .......................................................................................................................... 841
Using jQuery Mobile Collapsible Sets (Accordions) ...................................................................843
Configuring the Collapsible Set ......................................................................................................................... 844
Using the Collapsible Set Methods .................................................................................................................... 845
Using the Collapsible Set Events ....................................................................................................................... 845
Chapter 31: Using jQuery Mobile Forms ........................................................................847
Creating Form Element Widgets ................................................................................................848
Using the Textinput Widget ........................................................................................................851
Configuring the Textinput Widget ....................................................................................................................... 851
Using the Textinput Widget Methods ................................................................................................................. 852
Using the Textinput Widget Events .................................................................................................................... 853
Using the Slider and Range Slider Widgets ...............................................................................853
Configuring the Slider and Range Slider Widgets .............................................................................................. 856
Using the Slider and Range Slider Methods ...................................................................................................... 857
Using the Slider Events ......................................................................................................................................859
Using the Range Slider Events
Using the Selectmenu Widget ...................................................................................................861
Configuring the SelectMenu Widget .................................................................................................................. 862
Using the Selectmenu Methods ......................................................................................................................... 866
Using the Selectmenu Events ............................................................................................................................ 868
Using Flip Switches ...................................................................................................................868
Using the Checkboxradio Widget ...............................................................................................869
Creating Check Boxes ........................................................................................................................................869
Creating and Formatting Radio Buttons ............................................................................................................ 874
Configuring the Checkboxradio Widget ............................................................................................................. 876
Using the Checkboxradio Methods .................................................................................................................... 876
Using the Checkboxradio Events ....................................................................................................................... 877
Chapter 32: Using Lists and Panels ...............................................................................879
Using the ListView Widget .........................................................................................................880
Configuring the Listview Widget ........................................................................................................................ 882
Using the Listview Methods .............................................................................................................................. 894
Using the Listview Events .................................................................................................................................. 894
Using the Panel Widget .............................................................................................................894
Configuring the Panel Widget ............................................................................................................................ 896
Using the Panel Methods ...................................................................................................................................900
Using the Panel Events ......................................................................................................................................901
Chapter 33: Refactoring the Example: Part IV ...............................................................903
Starting with the Basics ............................................................................................................903
Inserting Products Programmatically ........................................................................................905
Reusing Pages ...................................................................................................................................................909
Creating the Shopping Basket ...................................................................................................912
Adding for Quantity Changes ............................................................................................................................. 916
Adding a Button to the Information Page .......................................................................................................... 920
Implementing the Checkout Process
Chapter 34: Using the jQuery Utility Methods ...............................................................929
Queues Revisited: Using General Purpose Queues ....................................................................929
Manually Processing Queue Items .................................................................................................................... 932
Utility Methods for Arrays ..........................................................................................................933
Using the Grep Method ......................................................................................................................................933
Using the inArray Method .................................................................................................................................. 935
Using the Map Method ......................................................................................................................................935
Using the Merge Method ...................................................................................................................................937
Using the Unique Method .................................................................................................................................. 937
Utility Methods for Types ...........................................................................................................938
Using the Type Method ......................................................................................................................................939
Utility Methods for Data .............................................................................................................940
Serializing Form Data ........................................................................................................................................940
Parsing Data ......................................................................................................................................................941
Trimming Strings ...............................................................................................................................................941
Other Utility Methods .................................................................................................................942
Checking Element Containment ........................................................................................................................ 942
Chapter 35: The jQuery UI Effects & CSS Framework ....................................................945
Using the jQuery UI Effects ........................................................................................................945
Animating Colors ............................................................................................................................................... 946
Animating Classes .............................................................................................................................................948
Using the jQuery UI Animations ......................................................................................................................... 951
Using the jQuery UI CSS Framework .........................................................................................953
Using the Widget Container Classes .................................................................................................................. 953
Applying Rounded Corners ................................................................................................................................ 955
Using the Interaction State Classes ................................................................................................................... 957
Using the Cue Classes ...............................................................................................................................
Chapter 36: Using Deferred Objects ..............................................................................963
A First Deferred Objects Example .............................................................................................964
Understanding Why Deferred Objects Are Useful .............................................................................................. 966
Using Other Callbacks ...............................................................................................................973
Rejecting a Deferred Object ............................................................................................................................... 974
Covering Both Outcomes 

 Using Outcome-Indifferent Callbacks 
 Using Multiple Callbacks ....................................................................
Using the Outcomes of Multiple Deferred Objects ....................................................................983
Providing Progress Information .................................................................................................984
Getting Information about a Deferred Object ............................................................................988
Using Ajax Deferred Objects

No comments:

Post a Comment