作者:_BEAR BIBEAULT 页数:486 出版社:empty |
This is en excel nt avk, aaorthyswceessor to others in Manning sTu Ad on series.ht ishighly rend d able and chock-fall af working red de.The Lab pages area maravieusavrylo explorethe librar g, in hich should he cowen nimporlantpartofrueryael de or loperS arsenal Moes larsall round l!] highly ree ommend the book for learning the fundamen in lsofjQueryanelthenseruin gas a goodwf even cr book as you leverage the powrrofjQuey more and wore in your daily dr on lop wentThe EJe ments of Style for Jaw n Scrip a.For thore new to j Query, this book is a good prier that cov sn range of common nssa f theframe ak....The r xamples through oul the look are srl evan l, and make the pu in l effect iu ely.The code snippets arc easly distinguishable fiom the rest of the text, and the text is dear andrnsyiofollouIi works and makes furaveryrradubirboue that you can just breeze through very quic hly andpickup and sefa in alot of informationThanks to the anthorsBearBibenult and} ehud a Katz and their exe wp lary style, this cow pre-hensive l wok, or operating manual as if might be eul led, can Jel a henin afr onE-lo-sack ap prava chlo learn from s crutch, or as a referenc clo those alr early da bling in jQueryandueedingeerifica-tion af best practice i.wzhitseapobletechuicalco we rage.exten she usr of saw ple code, nndopproarhablestl,j Query in Action i save lu able se source for any Web de un loper seeking to maximize the powerof Ja on So ipt and a must-han v for anyone interested in leur ning j Quey-David Sils.Java Lnb by, D zoneDenver OpenSource Users GroupWebDeveloper, Sash dot Contributor-Joshua Heyer, Tran eIne.-Grant Palin, Blogger—Rich Strahl, Blogger-Matthew McCullough,—Michael J.Ross,
For on nc informaton and ordering of this and other Manning books, please visitwww.manning.com.Thepublsheroffersdiscountsonthisbookwhenorderedinquantty.For more info n nation.please contacte2010by Manning Publications Co.All rights reserved.No part of this publication maybe reproduced, so red in a retrieval system, or transmitted, inany form or by means electronic.mechanical, photocopying.or otherwise, without prior writtenpermission of the publisher.Many of the designations used by manufacturers and sellers to distinguish their products areclaimed as trademarks.Where those designations appear in the book, and ManningPublic a tons was aware of at a demark c aim, the design a in shave been printed in intal capsor all caps.@Recognizing the import an cc of presen ving what has been written, it is Manning x policy to havethe books we publish printed on acid free paper, and we exert our best cfl orts to that end.Recognizing abso our responsibility to conserve the resources of our planet, Manning booksare printed on paper that is atleast l 5 percent recycled and p to cessed without the use ofclement al chlorine.ISBN 978-1-995182-3200Printed in the United States of America12345678910-MAL-151419121110
foreword to the first edition
It's all about simplicity.Why should we h developers he forced to write long, complex,book length pieces of code when they want to create simple pic ces of interaction?There's nothing that says that complexity has to be a requirement for developing webapplications.When I first set out to create j Query I decided that I wanted anc in phasis on smallsimple code that served all the practical applications that we h developers deal withday today I was greatly pleaser las I read through j Query in Action to see in it an excel-lent manifestation of the principles of the j Query libraryWith an overwhelming emphasis on practical, real world code presented in a terse,to the point format, j Query in Action will serve as an ideal resource for those lookingto familiarize themselves with the library.What's pleased me the most about this hook is the significant attention to detailthat Bear and Yehuda have paid to the inner workings of the library, They were thorough in their investigation and disse in i nation of the j Query APL It felt like nary a daywent hy in which I was n't graced with an email or instant message from the maskingfor ean fication, re porn g newly di covered bugs, or recommending improvements tothe library.You can he safe knowing that the resource that you have before you is oneof the best thought nut and researched pieces of literature on the j Query libraryOne thing that surprised me about the contents of this book is the explicit inclusion of j Query plugins and the tactics and theory behind j Query plugin developmentThe reason why j Query is able to stay so simple is through the use of its plugin
FD REWORD TO THE FIRST EDITION
architecture.lt provides a number of documenter extension points upon which plugins can add functionality.Often that functionality, while useful, is not genericenough for inclusion in j Query itself which is what makes the plugin architecturenecessary.A few of the plugins rl is cussed in this hook, like the Forms, Dimension, andLive Query plugins,haveseenwidespreadadoptionandthereasonisohvious:They'reexpertly constructed, documented, and maintained.Be sure to pay special attentionto how plugins are utilize rand constructed as their use is fundamental to the j Queryexperience.With resources like this hook, the j Query project is sure to continue to grow andsucceed.I hope the hook will end up serving you well as you he gin your explorationand use of j QueryIr sheen two years since their st edition of jQ ury in Actin was published.Was it reallynecessary to update the hook so soon?JOHN RE SIGCREATOR OF j QUERYpreface to the second edition
Compared to the steady world of server-side languages such as Java, the clientsidetechnologies of the web move at a mighty fast clip.And j Query isnt eating anyonesdust; rather, it'sat the forefront of the rush!The j Query team releases a major new version of the library just about every year(lately, striving for every January) , in addition to the minor updates that are madethroughout the calendar year.That means that there have been numerous minorreleases, and two major versions since the publication of the first edition, which waswritten against j Query 1.2.And what updates j Query 1.3andjQueryl. 4 have been!With each major release, the capabilities of j Query have been extended andenhanced insignificant ways.Whether it be the addition of custom events, eventnamespaces, function and ef feet queuing, or simply the large handful of really usefulmethods and functions that have been added, the range of cap abl ities that j Queryspans has increased sign if cant lysine e the first edition hit the standsAnd that doesn't even consider j Query UI!In its nascent stages two years ago,j Query UI merited a few sections in one chapter of the first edition.Since then, j QueryUl has grown in scope and maturity and warrants a complete book part in this edition,consisting of three full chaptersSo it should come as no surprise that this second edition has made its way on tothe shelves cow ring the advances that j Query and j Query UI have made over the pasttwo years
PREFACE TO THE SECOND EDITIONWhat's new in the second edit lon?When we decided to goahead with creating a second edition of j Query in Action, Iremember someone si ying to me, “Should be apiece of cake.After all, you just needto make some updates to the first edition.How wrong they were lIt actually took longer to complete this second edition thanto write the book in the first place.You see, we didn't want to fall into the trap of“phoning it in by just adding updates here and there and calling it done.We wantedthis second edition to be much more than a warmed over version of the first edition.Anyone comparing the tableofcontents of the first and second editions of thisbook will note that the structure of chapters 1through8hasn't changed all thatmuch.But that's pretty much where the similarities stop.This second edition is n't just a tepid rehash of the first edition with some extrainformation sprinkled here and there.Each and every paragraph in the text, and eachand every line in the example code, has undergone a careful inspection.Not onlyhave the additions and changes made to j Query between versions 1.2 and 1.4 beentaken into account, the information in the chapters and the example co dc have beenupdated to reflect current hest practices regarding page scripting and the use ofj Query.Atter all, as a community, weve got two more years of experience writinghighly interactive scripted pages using j Query under our belts.Every example has heen examined and either updated to better show howto usej Query 1.4in practice, or replaced with an example that is better suited to show easingthe concepts he ing discussed.For example, read lers of the first edition may rememberthe comprehensive Bam hoo Grille example at the end of chapter 4 that highlightedj Query event handling Try as we might, we were unable to reshape that example toflaunt the newest j Query event handing concepts, such as“live and custom eventsSo it has been completely replaced with the DVD Ambassador example that serves as abetter vehicle for demonstrating the advanced event handling concepts.The second part of the book, focusing on j Query UI, is completely new material,covering the extensive changes that j Query UT has undergone since the first editionwas publ shed.We'd estimate that, counting the additions, replacements, and updates of thematerial presented throughout the first part of the book, as well as the completely newcontent of part 2, that atleast 50 percent of this second edition is brandnew materialThe other 50 percent has undergone extensive rework to ensure that it is uptodateand reflective of modern hest practices.So much for the piece of cake!On c of your authors is a grizzled veteran whose involvement in progra tn ming datesback to when FORTRAN was the bomb, and the other is an enthusiastic domainexpert, siv vy beyond his years, who's barely ever known a world without an InternetHow did two people with such disparate backgrounds come together to work on ajoint project?preface to the first editionThe answer is, obv in us ly, j QueryThe paths by which we came together over our affection for this most useful of cli-ent-side tools areas different as night and dayI(Bear) first hear of j Query while I was working on Ajax in Practice.Near the endof the creation cycle of abn ok is a whirlwind phase known as the copyedit when thechapters are reviewed for grammatical correctness and clarity(among other things)by the copyeditor and for technical correctness by the technical editor.Atleast for me,this is the most frenc tic and stressful time in the writing of a book, and the last thing Iwant to hear is you really should add a completely new section.One of the chapters I contributed to Ajax in Pract ce surveys a number of Ajaxenabling clientside libraries, one of which I was already quite familiar with(Prototype) and others(the Dojo Toolkit and DWR) on which I had to come up to speedpretty quickly.While jugg ing what seemed like a zillion tasks(all the while holding down a dayjob, running aside business, and dealing with household issues, the technical erl it or,Valentin Cre ttz, casually drops this bomb:“So why don't you have a section onj Query?”
Introducing j Query3
1.1
PART l
Power in the economy of code 4
Unobtrusive JavaScript 6
1.3j Query fundamentals 8
1.4 Summary 16
Se parra tig behavior from structure 6·Srg rrg uting the script 7
The jQueyuvapper 8.Unlit y functions l 1·The document
i Query 14-Using j Query with other hl varies 16
13·Extending
Selecting the elements upon which to act
2.1 Selecting elements for manipulation 19
2.2 Generating new HTML 32
2.4 Summary 54
Bringing pages to ie with j Query55
3.1Working with element properties and attributes 56
3.2 Changing element styling 65
3.3 Setting element content 77
3.4 Dealing with form element values 89
3.5 Summary 92
Events are where it happens ! 93
4.1