Being part of the core jQuery team, I've had the opportunity to come to know Karl quite well over the past couple years, and especially within the context of his book writing effort. [r]
Trang 2Learning jQuery 1.3
Better Interaction Design and Web Development with Simple JavaScript Techniques
Jonathan Chaffer
Karl Swedberg
BIRMINGHAM - MUMBAI
Trang 3Learning jQuery 1.3
Copyright © 2009 Packt Publishing
All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the authors, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged
to be caused directly or indirectly by this book
Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information First published: February 2009
Production Reference: 1040209
Published by Packt Publishing Ltd
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK
ISBN 978-1-847196-70-5
www.packtpub.com
Cover Image by Karl Swedberg (karl@englishrules.com)
Trang 4Authors
Jonathan Chaffer
Karl Swedberg
Reviewers
Akash Mehta
Dave Methvin
Mike Alsup
Senior Acquisition Editor
Douglas Paterson
Development Editor
Usha Iyer
Technical Editor
John Antony
Editorial Team Leader
Akshara Aware
Production Editorial Manager
Abhijeet Deobhakta
Project Team Leader
Lata Basantani
Project Coordinator
Leena Purkait
Indexer
Rekha Nair
Proofreader
Jeff Orloff
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagata The Gigapedia Team
Trang 5I feel honored knowing that Karl Swedberg and Jonathan Chaffer undertook the task
of writing Learning jQuery As the first book about jQuery, it set the standard that other jQuery — and, really, other JavaScript books in general — have tried to match It's consistently been one of the top selling JavaScript books since its release, in no small part due to its quality and attention to detail
I'm especially pleased that it was Karl and Jonathan who wrote the book since I already knew them so well and knew that they would be perfect for the job Being part of the core jQuery team, I've had the opportunity to come to know Karl quite well over the past couple years, and especially within the context of his book writing effort Looking at the end result, it's clear that his skills as both a developer and a former English teacher were perfectly designed for this singular task
I've also had the opportunity to meet both of them in person, a rare occurrence in the world of distributed Open Source projects, and they continue to be upstanding members of the jQuery community
The jQuery library is used by so many different people in the jQuery community The community is full of designers, developers, people who have experience
programming, and those who don't Even within the jQuery team, we have people from all backgrounds providing their feedback on the direction of the project There
is one thing that is common across all of jQuery's users, though: We are a community
of developers and designers who want JavaScript development to be made simple
It's almost a cliché, at this point, to say that an open source project is community-oriented, or that a project wants to focus on helping new users get started But it's not just an empty gesture for jQuery; it's the liquid-oxygen fuel for the project We actually have more people in the jQuery team dedicated to managing the jQuery community, writing documentation, or writing plugins than actually maintaining the core code base While the health of the library is incredibly important, the
community surrounding that code is the difference between a floundering, mediocre project and one that will match and exceed your every need
Trang 6[ 420 ]
plugins, writing
$ alias, using 369
documentation style 370
method interfaces 369
naming conventions 368, 369
Plugin Repository 317
pointers 395
Q
queued effects 82
R
reference counting system 394
reference loop 395
rows, table appearances
highlighting 181, 182
highlighting, with user interaction 186-188
striping 182-184
striping, advanced methods 185
S
Safari tools
about 381
Develop Menu 381
Web Inspector 382
security limitations
<iframe> HTML tag, using 144
JSONP, using for remote data 144
remote data, loading 143
selector expression
:first, 399
:last, 399
:not(a), 399
:even, 399
:odd, 399
:eq(index),400
:gt(index), 400
:lt(index), 400
:header, 400
:animated, 400
:contains(text), 400
:empty, 400
:has(a), 400
:parent, 400
:hidden, 400
:visible, 400
:nth-child(index), 400 :nth-child(even), 400 :nth-child(odd), 400 :nth-child(formula), 400 :first-child, 400
:last-child, 400 :only-child, 400 :input, 400 :text, 400 :password, 400 :radio, 400 :submit, 401 :image, 401 :reset, 401 :button, 401 :file, 401 :enabled, 401 :disabled, 401 :checked, 401 :selected, 401
#id, 399
*, 399 class, 399 [attr=value], 400 [attr!=value], 400 [attr^=value], 400 [attr$=value], 400 [attr*=value], 400 [attr], 400
a ~ b, 399
a + b, 399
a > b, 399
a b, 399
a, b, 399 element, 399 creating 365 list 399, 400 parameters, element 366 parameters, index 366 parameters, matches 366 parameters, set 366 pseudo-class, adding 365 using 365-367
selectors
custom selectors 26
server-side pagination
about 171
Trang 7[ 421 ]
sorting and paging 171, 172
server-side sorting, sorting
page refreshes, eliminating 153
progressive enhancement example 153
query string used 152
shortcut methods, adding
.animate() method 355
advantage 355
custom shortcut methods 356, 357
elements, hiding 355
elements, showing 355
event methods 354
show() method
disadvantage 74
example 72, 73
features 72
show(fast) method, using 74
show(normal) method, using 74
show(slow) method, using 74
show(speed), method 74
sorting
about 152
JavaScript sorting 153
server-side sorting 152
sorting and paging code 178-180
style switcher, events
codes, executing 46
default button, enabling 43
event context, exploiting 46
handler context 43, 44, 45
keyboard events, adding 63
large print button, enabling 41
narrow column button, enabling 42
refactoring 45
styling
alternate rows 27-29
category cell 31, 32
links 25
T
table appearances, modifying
clickable class 189
filtering 196
JavaScript code 202-205
rows, highlighting 181
sections, collapsing 194, 196
sections, expanding 194, 196
tooltip 189 tooltip, hiding 191 tooltip, placing 190 tooltip, positioning 190 tooltip, showTooltip() function 192, 194 tooltip, text styling 192
tables, plugins
Flexigrid plugin 334 jqGrid plugin 333 Tablesorter plugin 333
tabular data
about 151 paginating 171 paging 152 sorting 152
tools
Aptana tool 383 Charles tool 383 Fiddler tool 383 Firebug Lite tool 382 Firefox tools 379 Internet Explorer tools 381 NitobiBug tool 383 Opera tools 382 Safari tools 381 TextMate jQuery tool 383
U user events, plugins
hoverIntent plugin 340 Live Query plugin 340
V Venkman, Firefox tools 380
W
W3C 374 Wide Web Consortium See W3C
X XMLPath Language (XPath) 24 Z
zero- based numbering, custom selectors 26