Download PDF : Learning jQuery too easy

 Download PDF : Learning jQuery too easy 





 Download PDF : Learning jQuery too easy















Chapter 1: Getting Started 
What jQuery does 9
Why jQuery works well 11
Our first jQuery-powered web page 12
Downloading jQuery 12
Setting up jQuery in an HTML document 13
Adding our jQuery code 16
Finding the poem text 17
Injecting the new class 17
Executing the code 17
The finished product 19
Plain JavaScript vs. jQuery 19
Development tools 20
Firebug 21
Summary 24

Chapter 2: Selecting Elements 
The Document Object Model 25
The $() function 27
CSS selectors 28
Styling list-item levels 29
Attribute selectors 31
Styling links 31
Custom selectors 34
Styling alternate rows 34
Form selectors 39
DOM traversal methods 39
Styling specific cells 41
Chaining 43
Accessing DOM elements 44
Summary 45
Further reading 45
Exercises 45

Chapter 3: Handling Events 
Performing tasks on page load 47
Timing of code execution 47
Multiple scripts on one page 48
Shortcuts for code brevity 50
Passing an argument to the .ready() callback 50
Simple events 51
A simple style switcher 51
Enabling the other buttons 54
Event handler context 55
Further consolidation 57
Shorthand events 59
Compound events 61
Showing and hiding advanced features 61
Highlighting clickable items 63
The journey of an event 65
Side effects of event bubbling 66
Altering the journey: the event object 67
Event targets 68
Stopping event propagation 69
Default actions 70
Event delegation 70
Methods for event delegation 73
Removing an event handler 74
Event namespacing 75
Rebinding events 75
Simulating user interaction 78
Keyboard events 79
Summary 82
Further reading 83
Exercises 83

Chapter 4: Styling and Animating 
Inline CSS modification 85
Basic hide and show 90
Effects and speed 92
Speeding in 93
Fading in and fading out 94
Sliding up and sliding down 94
Compound effects 95
Creating custom animations 97
Building effects by hand 98
Animating multiple properties at once 99
Positioning with CSS 101
Simultaneous versus queued effects 103
Working with a single set of elements 103
Bypassing the queue 104
Manual queueing 105
Working with multiple sets of elements 107
Callbacks 109
In a nutshell 111
Summary 111
Further reading 112
Exercises 112

Chapter 5: Manipulating the DOM 
Manipulating attributes 113
Non-class attributes 114
Value callbacks 115
DOM element properties 118
DOM tree manipulation 119
The $() function revisited 119
Creating new elements 119
Inserting new elements 120
Moving elements 122
Wrapping elements 124
Inverted insertion methods 126
Copying elements 129
Cloning for pull quotes 130
Content getter and setter methods 133
Further style adjustments 135
DOM manipulation methods in a nutshell 136
Summary 137
Further reading 138
Exercises 138

Chapter 6: Sending Data with Ajax 
Loading data on demand 139
Appending HTML 141
Working with JavaScript objects 144
Retrieving JSON 144
Global jQuery functions 146
Executing a script 149
Loading an XML document 151
Choosing a data format 154
Passing data to the server 155
Performing a GET request 156
Performing a POST request 160
Serializing a form 161
Delivering different content for Ajax requests 164
Keeping an eye on the request 165
Error handling 168
Ajax and events 169
Security limitations 170
Using JSONP for remote data 172
Additional options 174
The low-level Ajax method 174
Modifying default options 175
Loading parts of an HTML page 175
Summary 178
Further reading 178
Exercises 179

Chapter 7: Using Plugins 
Finding plugins and help 181
How to use a plugin 182
Downloading and referencing the Cycle plugin 182
Simple plugin use 182
Specifying plugin method parameters 184
Parameter defaults 185
Other types of plugins 186
Custom selectors 186
Global function plugins 187
The jQuery UI plugin library 188
Effects 189
Color animations 189
Class animations 190
Advanced easing 190
Additional effects 191
Interaction components 192
Widgets 194
jQuery UI ThemeRoller 197
Summary 197
Exercises 198

Chapter 8: Developing Plugins 
Use of the $ alias in plugins 199
Adding new global functions 200
Adding multiple functions 202
Adding jQuery object methods 205
Object method context 206
Implicit iteration 207
Method chaining 208
Method parameters 209
Parameter maps 211
Default parameter values 212
Callback functions 213
Customizable defaults 214
The jQuery UI widget factory 216
Creating a widget 217
Destroying widgets 219
Enabling and disabling widgets 220
Accepting widget options 220
Adding sub-methods 221
Triggering widget events 222
Plugin design recommendations 223
Plugin distribution 224
Summary 224
Exercises 225

Chapter 9: Advanced Selectors and Traversing 
Selecting and traversing revisited 227
Dynamic table filtering 229
Table row striping 231
Combining filtering and striping 233
More selectors and traversal methods 234
Customizing and optimizing selectors 235
Writing a custom selector plugin 235
Selector performance 237
Sizzle selector implementation 238
Testing selector speed 239
DOM traversal under the hood 240
jQuery object properties 241
The DOM element stack 243
Writing a DOM traversal method plugin 244
DOM traversal performance 246
Improving performance using chaining 246
Improving performance using caching 247
Summary 248
Further reading 248
Exercises 248

Chapter 10: Advanced Events 
Events revisited 251
Loading additional pages of data 253
Displaying data on hover 254
Event delegation 256
Using jQuery's delegation methods 257
Choosing a delegation method 257
Delegating early 259
Using a context argument 260
Custom events 260
Infinite scrolling 262
Custom event parameters 263
Throttling events 264
Other ways to perform throttling 265
Special events 266
More about special events 268
Summary 268
Further reading 269
Exercises 269

Chapter 11: Advanced Effects 
Animation revisited 271
Observing and interrupting animations 274
Determining the animation state 274
Halting a running animation 275
Caution when halting animations 276
Global effect properties 276
Globally disabling all effects 276
Fine-tuning animation smoothness 277
Defining effect durations 277
Multi-property easing 280
Deferred objects 281
Animation promises 282
Summary 285
Further reading 285
Exercises 286

Chapter 12: Advanced DOM Manipulation 
Sorting table rows 287
Server-side sorting 287
Ajax sorting 288
JavaScript sorting 289
Moving and inserting elements, revisited 290
Adding links around existing text 290
Sorting simple JavaScript arrays 291
Sorting DOM elements 292
Storing data alongside DOM elements 294
Performing additional precomputation 295
Storing non-string data 296
Alternating sort directions 299
Using HTML5 custom data attributes 300
Sorting and building rows with JSON 303
Modifying the JSON object 305
Rebuilding content on demand 306
Advanced attribute manipulation 308
Shorthand element creation 308
DOM manipulation hooks 309
Writing a CSS hook 310
Summary 312
Further reading 312
Exercises 313

Chapter 13: Advanced Ajax 
Progressive enhancement with Ajax 315
Harvesting JSONP data 317
Ajax error handling 321
The jqXHR object 323
Ajax promises 323
Caching responses 325
Throttling Ajax requests 327
Extending Ajax capabilities 328
Data type converters 328
Ajax prefilters 333
Alternate transports 334
Summary 338
Further reading 338
Exercises 339
Appendix A: JavaScript Closures 341
Inner functions 341
The great escape 343
Variable scoping 344
Interactions between closures 346
Closures in jQuery 347
Arguments to $(document).ready() 348
Event handlers 348
Binding handlers in loops 350
Named and anonymous functions 352
Memory leak hazards 353
Accidental reference loops 354
The Internet Explorer memory leak problem 355
The good news 356
Summary 356
Appendix B: Testing JavaScript with QUnit 357
Downloading QUnit 358
Setting up the document 358
Organizing tests 359
Adding and running tests 360
Asynchronous testing 363
Other types of tests 364
Practical considerations 364
Further reading 365
Summary 366
Appendix C: Quick Reference 367
Selector expressions 367
Simple CSS 367
Position among siblings 368
Position among matched elements 368
Attributes 369
Forms 369
Other custom selectors 370
DOM traversal methods 370
Filtering 370
Descendants 371
Table of Contents
[ ix ]
Siblings 371
Ancestors 372
Collection manipulation 372
Working with selected elements 373
Event methods 373
Binding 374
Shorthand binding 374
Special shorthands 376
Triggering 376
Shorthand triggering 376
Utility 377
Effect methods 377
Predefined effects 377
Custom animations 378
Queue manipulation 378
DOM manipulation methods 378
Attributes and properties 378
Content 379
CSS 379
Dimensions 380
Insertion 381
Replacement 381
Removal 382
Copying 382
Data 382
Ajax methods 382
Issuing requests 383
Request monitoring 383
Configuration 384
Utilities 384
Deferred objects 384
Object creation 384
Methods of deferred objects 385
Methods of promise objects 385
Miscellaneous properties and functions 385
Properties of the jQuery object 386
Arrays and objects 386
Object introspection 386
Other 387
Index 389





Download Learning jQuery too easy / PDF












 Download PDF : Learning jQuery too easy 

0 commentaires: