INTRODUCTION

OVER THE PAST SEVERAL YEARS JAVASCRIPT has undergone a remarkable transformation. Where once it was a “toy” language relegated to secondary status it’s now one of the most important programming languages in the world. With the ongoing importance of Ajax-based development and the rise of full-featured JavaScript libraries, the stigma surrounding JavaScript has all but vanished. As easily the most popular and beginner-friendly library, jQuery is responsible for the lion’s share of that progress.

jQuery is more than just a beginner’s choice; however, it’s in use at some of the largest organizations in the world, adding interactivity to billions of page views every month. Amazon, IBM, Twitter, NBC, Best Buy and Dell are just a few of the companies using jQuery in production.

With a web-scale footprint it should come as no surprise that jQuery is evolving at web speed. 2011 saw no less than three major releases and the community surrounding jQuery continues to blossom as developers the world over contribute bug fixes, plugins and work on related projects like jQuery UI and QUnit. This flurry of activity ensures that jQuery presents a full-featured option for any developer looking to do world-class JavaScript development.

This is true no matter what programming philosophy or technique is followed: jQuery is prominently featured in the front end of Java/Spring, PHP, .NET, Ruby on Rails, and Python/Django stacks all over the Web.

If you have experience with HTML, CSS, and JavaScript, then this book is for you. This book will expand your jQuery knowledge by focusing on the core library with the benefit of strong core JavaScript expertise coloring the lessons. The first few chapters will help you to set up a development environment, and reviews important JavaScript concepts. Chapters 3 to 7 examine the jQuery core concepts. The second half of the book focuses on applying jQuery in the real world, detailing jQuery UI, plugin development, templates, unit testing, best practices, and JavaScript design patterns applied with jQuery.

Hopefully, this book will give you the hardcore jQuery chops you’ll need to solve whatever problems the Web throws at you.

WHO THIS BOOK IS FOR

This book is aimed at three groups of readers:

  • Experienced server-side web application developers looking to move more heavily into the client side using the world’s most popular front-end library
  • Experienced JavaScript programmers looking to ramp up quickly on jQuery
  • Novice to intermediate jQuery developers looking to expand their jQuery knowledge into more advanced topics

This book is not aimed at beginners. For beginners looking to start from the basics of HMTL, CSS, and JavaScript/jQuery development, Beginning JavaScript and CSS Development with jQuery (Wrox Programmer to Programmer) by Richard York is a more appropriate choice.

WHAT THIS BOOK COVERS

Professional jQuery provides a developer-level introduction to jQuery as well as providing an in-depth look at more advanced features.

Starting with the first part, the book offers an in-depth introduction to jQuery fundamentals, selecting elements, manipulating to the DOM, and binding and reacting to browser events.

Building on that solid foundation the book will outline more advanced topics, including plugin development, unit testing with JavaScript and other advanced features of the library.

The book focuses on features available as of jQuery 1.7.1, but tries to make note of feature support in older versions of the library wherever relevant.

HOW THIS BOOK IS STRUCTURED

This book is divided into two parts, jQuery Fundamentals and Applied jQuery. jQuery Fundamentals introduces the core concepts and Applied jQuery focuses on more advanced subjects.

Part 1 — jQuery Fundamentals consists of the following chapters:

1. Getting Started — This chapter sets up an environment for developing and debugging jQuery and JavaScript code and defines the code standards that will be used throughout the book. It also talks about ways to package JavaScript for production and sets up code.

2. JavaScript Primer — This chapter goes through the basics of the JavaScript programming language to firm up the foundation upon which the rest of the book is built. jQuery is a JavaScript library after all, and many of the best features spring from clever application of core JavaScript techniques.

3. The jQuery Core — Introduces the basic functions that make up the library. It illuminates usages of the core jQuery functions and then introduces many of the utility functions that you’ll use to perform a variety of tasks.

4. DOM Element Selection and Manipulation — This chapter dives into one of the core features of jQuery, the ability to select and manipulate HTML elements.

5. Event Handling — Introduces another key feature of jQuery, the cross-browser ability to bind and manage browser events.

6. HTML Forms, Data, and Ajax — Explores one of the biggest revolutions in web development of the past 10 years — Ajax.

7. Animations and Effects — Explores some of the shortcuts that jQuery offers for animating components in your web applications such as moving, fading, toggling, and resizing elements.

Part 2 — Applied jQuery covers the following topics:

8. jQuery UI Part I: Making Things Look Slick — Introduces jQuery UI. jQuery UI is an associated user interface library for jQuery that contains widgets, effects, animations, and interactions.

9. jQuery UI Part 2: Mouse Interactions — Explores additional jQuery UI features including moving, sorting, resizing, and selecting elements with the mouse.

10. Writing Effective jQuery Code — Teaches a variety of techniques, best practices, and patterns that you can apply to your code immediately to make it more efficient, maintainable, and clear.

11. jQuery Templates — Focuses on the jQuery Template plugin. jQuery templates are a standard way of marrying data and markup snippets.

12. Writing jQuery Plugins — Focuses on authoring jQuery plugins. Being able to extend the power of jQuery with custom methods is a fundamental skill for a top jQuery developer.

13. Advanced Asynchronous Programming with jQuery Deferred — Introduces the jQuery Deferred object. $.Deferred, introduced in version 1.5, is a chainable utility object that provides fine-tuned control over the way callback functions are handled.

14. Unit Testing with QUnit — Introduces the general concept of unit testing and goes into detail with the specific unit testing framework created and used by the jQuery project itself, QUnit.

WHAT YOU NEED TO USE THIS BOOK

jQuery supports the following web browsers. You’ll need one of them to run the samples provided with the book:

  • Firefox 3.6, Current – 1 version
  • Internet Explorer 6+
  • Safari 5.0.x
  • Opera Current – 1 version
  • Chrome Current – 1 version

CONVENTIONS

To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book.

image

Boxes with a warning icon like this one hold important, not-to-be-forgotten information that is directly relevant to the surrounding text.

image

The pencil icon indicates notes, tips, hints, tricks, and asides to the current discussion.

As for styles in the text:

  • We highlight new terms and important words when we introduce them.
  • We show keyboard strokes like this: Ctrl+A.
  • We show file names, URLs, and code within the text like so: persistence.properties.
  • We present code in two different ways:
We use a monofont type with no highlighting for most code examples.
 
We use bold to emphasize code that is particularly important in the present context or to show changes from a previous code snippet.

SOURCE CODE

As you work through the examples in this book, you may choose either to type in all the code manually, or to use the source code files that accompany the book. All the source code used in this book is available for download at http://www.wrox.com. When at the site, simply locate the book’s title (use the Search box or one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book. Code that is included on the website is highlighted by the following icon:

image

Listings include the filename in the title. If it is just a code snippet, you’ll find the filename in a code note such as this:

Code snippet filename

image

Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-1-118-02668-7.

Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at http://www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books.

ERRATA

We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, like a spelling mistake or faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save another reader hours of frustration, and at the same time, you will be helping us provide even higher quality information.

To find the errata page for this book, go to http://www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page, you can view all errata that has been submitted for this book and posted by Wrox editors. A complete book list, including links to each book’s errata, is also available at www.wrox.com/misc-pages/booklist.shtml.

If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport.shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.

P2P.WROX.COM

For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums.

At http://p2p.wrox.com, you will find a number of different forums that will help you, not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps:

1. Go to p2p.wrox.com and click the Register link.

2. Read the terms of use and click Agree.

3. Complete the required information to join, as well as any optional information you wish to provide, and click Submit.

4. You will receive an e-mail with information describing how to verify your account and complete the joining process.

image

You can read messages in the forums without joining P2P, but in order to post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.

For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works, as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset