Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introducing design patterns


If you've spent any time developing code in jQuery, then it is very likely that you've created one or more plugins; these can technically range from just a handful of lines to something more substantial.

Over time, there is a risk that amending code in plugins can lead to content becoming unwieldy and difficult to debug. One way of dealing with this is to use design patterns. We covered this back in Chapter 3, Organizing Your Code. Many of the same principles can equally apply to plugins, although the patterns themselves will of course be different. Let's consider a few examples.

The most basic pattern is A Lightweight Start, which will suit those who have developed plugins before, but are new to the concept of following a specific pattern. This particular pattern is based around common best practices, such as using a semicolon before invoking the function; it will pass in standard arguments such as window, document, and undefined. It contains a basic default object...