CHAPTER 1 . PUTTING JQUERY IN CONTEXT 5

CHAPTER 1 . PUTTING JQUERY IN CONTEXT 5 Part 5: Using jQuery Mobile jQuery Mobile is the other user interface library that I cover in this book. jQuery Mobile is built on top of jQuery and incorporates some basic feature from jQuery UI but has been optimized for creating smartphone and tablet interfaces. Fewer user interface widgets are available in jQuery Mobile, but those that are supported are optimized for touch interaction and for use presentation on smaller displays. Part 6: Advanced Features The final part of this book describes some jQuery and jQuery UI features that are not commonly used but that can be helpful in complex projects. These are advanced features that require a better understanding of HTML, CSS, and jQuery itself. In the case of Chapter 35, a basic knowledge of asynchronous programming is very helpful. Are There Lots of Examples? There are loads of examples. One of the nice aspects of jQuery is that almost any task can be performed in several different ways, allowing you to develop a personal jQuery style. To show the different approaches you can take, I have included a lot of different examples so many, in fact, that I include the complete HTML document you are working with only once in each chapter in order to fit everything in. The first example in every chapter will be a complete HTML document, as shown in Listing 1-1, for example. Listing 1-1. A Complete Example Document

Jacqui’s Flower Shop

CHAPTER 1 . PUTTING JQUERY IN CONTEXT 4

CHAPTER 1 . PUTTING JQUERY IN CONTEXT 4 Understanding jQuery Plugins jQuery plugins extend the functionality of the basic library. There are some plugins that are so good and so widely used that I have covered them in this book. There are a lot of plugins available (although the quality can vary), so if you don t like the plugins I describe in this book, you can be confident that an alternative approach is available. What Do I Need to Know? Before reading this book, you should be familiar with the basics of web development, have an understanding of how HTML and CSS work, and, ideally, have a working knowledge of JavaScript. If you are a little hazy on some of these details, I provide refreshers for HTML, CSS, and JavaScript in Chapters 2, 3, and 4. You won t find a comprehensive reference for HTML elements and CSS properties, though. There just isn t the space in a book about jQuery to cover HTML in its entirety. If you want a complete reference for HTML and CSS, then I suggest another of my books: The Definitive Guide to HTML5, also published by Apress. What Is the Structure of This Book? This book is split into six parts, each of which covers a set of related topics. Part 1: Getting Ready Part 1 of this book provides the information you need to get ready for the rest of the book. It includes this chapter and primers/refreshers for HTML, CSS, and JavaScript. Later in this chapter, I ll describe the software that you will need in order to follow along. Part 2: Working with jQuery Part 2 of this book introduces you to the jQuery library, starting with a basic example and building up to include each of the core features: element selection, DOM manipulation, events, and effects. Part 3: Working with Data and Ajax Part 3 of this book shows how jQuery makes it possible to work with inline or remote data. I show you how you can generate HTML content from data, how you can validate data entered into web forms, and how you can use jQuery to perform asynchronous operations, including Ajax. Part 4: Using jQuery UI jQuery UI is one of the two user interface libraries that I describe in this book. Built on, and integrated with, the core jQuery library, jQuery UI allows you to create rich and responsive interfaces for your web applications.

C H A P T E R 1

C H A P T E R 1 3 Putting jQuery in Context At its heart, jQuery does something that sounds pretty dull: it lets you modify the contents of HTML documents by manipulating the model that the browser creates when it processes the HTML (known as DOM manipulation, as I ll explain later). If you are reading this, you have probably already done some DOM manipulation, either using another JavaScript library or even using the built-in API that most modern web browsers support, and you have picked up this book because you want to do it in a better way. jQuery goes beyond better. It makes DOM manipulation a pleasure and, on occasion, an actual joy. There is something so elegant and graceful about the way that jQuery works that transforms a task that can be pure drudgery into something that is simple and easy, and once you start using jQuery, there is no going back. Here are the top reasons that I use jQuery in my projects: jQuery is expressive. I can do more work with much less code than when using the browser DOM API. jQuery methods apply to multiple elements. The DOM API approach of selectiterate- modify is gone, meaning fewer for loops to iterate through elements and fewer mistakes. jQuery deals with implementation differences between browsers. I don t have to worry about whether IE supports a feature in an odd way, for example; I just tell jQuery what I want, and it works around the implementation differences. jQuery is open source. When I don t understand how something works or I don t quite get the result I was expecting, I can read through the JavaScript code and, if needed, make changes. Not everything is perfect, of course, and there are one or two rough edges, which I ll explain as I get into the details. But even with the occasional flaw, I love working with jQuery, and I hope you will find it equally compelling and enjoyable to use. To me, the genius of jQuery is that it takes something that is a major grind in web development and makes it simple, quicker, and easier. I can t ask for more than that. Understanding jQuery UI and jQuery Mobile In addition to the core jQuery library, I also cover jQuery UI and jQuery Mobile, which are user interface libraries built on top of the jQuery. jQuery UI is a general-purpose UI toolkit intended to be used on any device, and jQuery Mobile is designed for use with touch-enabled devices such as smartphones and tablets.

P A R T 1 Getting Ready

P A R T 1 Getting Ready

. CONTENTS v . Chapter 17: Setting Up

. CONTENTS v . Chapter 17: Setting Up jQuery UI ………………………………………………………………469 . Chapter 18: Using the Button, Progress Bar, and Slider Widgets………………….477 . Chapter 19: Using the Autocomplete and Accordion Widgets ……………………….513 . Chapter 20: Using the Tabs Widget……………………………………………………………549 . Chapter 21: Using the Datepicker Widget …………………………………………………..587 . Chapter 22: Using the Dialog Widget …………………………………………………………621 . Chapter 23: Using the Drag & Drop Interactions………………………………………….641 . Chapter 24: Using the Other Interactions …………………………………………………..673 . Chapter 25: Refactoring the Example: Part III …………………………………………….699 . Part 5: Using jQuery Mobile ……………………………………………………………………..727 . Chapter 26: Getting Started with jQuery Mobile ………………………………………….729 . Chapter 27: Pages and Navigation…………………………………………………………….761 . Chapter 28: Dialogs, Themes, and Layouts…………………………………………………791 . Chapter 29: Buttons and Collapsible Blocks……………………………………………….805 . Chapter 30: Using jQuery Mobile Forms …………………………………………………….827 . Chapter 31: jQuery Mobile Lists………………………………………………………………..853 . Chapter 32: Refactoring the Mobile Example: Part IV…………………………………..875 . Part 6: Advanced Features……………………………………………………………………….901 . Chapter 33: Using the jQuery Utility Methods……………………………………………..903 . Chapter 34: The jQuery UI Effects & CSS Framework …………………………………..921 . Chapter 35: Using Deferred Objects…………………………………………………………..939 . Index …………………………………………………………………………………………………….971

iv Contents at a Glance . About the

iv Contents at a Glance . About the Author…………………………………………………………………………………. xxviii . About the Technical Reviewer ………………………………………………………………… xxix . Acknowledgments …………………………………………………………………………………. xxx . Part 1: Getting Ready………………………………………………………………………………….1 . Chapter 1: Putting jQuery in Context …………………………………………………………….3 . Chapter 2: HTML Primer…………………………………………………………………………….13 . Chapter 3: CSS Primer ………………………………………………………………………………37 . Chapter 4: JavaScript Primer …………………………………………………………………….67 . Part 2: Working with jQuery ………………………………………………………………………97 . Chapter 5: jQuery Basics …………………………………………………………………………..99 . Chapter 6: Managing the Element Selection……………………………………………….123 . Chapter 7: Manipulating the DOM……………………………………………………………..153 . Chapter 8: Manipulating Elements…………………………………………………………….187 . Chapter 9: Working with Events ……………………………………………………………….223 . Chapter 10: Using jQuery Effects ………………………………………………………………247 . Chapter 11: Refactoring the Example: Part I ………………………………………………277 . Part 3: Working with Data and Ajax…………………………………………………………..291 . Chapter 12: Using Data Templates…………………………………………………………….293 . Chapter 13: Working with Forms ………………………………………………………………327 . Chapter 14: Using Ajax: Part I…………………………………………………………………..371 . Chapter 15: Using Ajax: Part II………………………………………………………………….399 . Chapter 16: Refactoring the Example: Part II ……………………………………………..431 . Part 4: Using jQuery UI…………………………………………………………………………….467

830 Appendix B . Entering the Linux Community (Web design programs)

830 Appendix B . Entering the Linux Community . Linux Online (www.linux.org/groups) Offers a large, international list of Linux User Groups. Select your country to see a list of available groups. . LinuxGazette GLUE (glue.linuxgazette.com) The Groups of Linux Users Everywhere (GLUE) site contains lists of known LUGs. If there is no Linux User Group in your area, you might consider starting one. To get information on what LUGs are all about and some suggestions about starting one, refer to the Linux User Group HOWTO (www.tldp.org/HOWTO/User-Group- HOWTO.html). . . .
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Web hosting resellers – Appendix B . Entering the Linux Community 829

Appendix B . Entering the Linux Community 829 Major Linux Projects As you know by now, the name Linux comes from the Linux kernel created by Linus Torvalds. The desktop, application, server, and other software needed to create a full Linux system are added from other open source projects. The following is a list of some of the major open source software organizations that usually have software included with Linux: . Free Software Foundation (www.fsf.org) Supports the GNU project, which produces much of the software outside the kernel that is associated with Linux. In particular, open source versions of nearly every early UNIX command have been implemented by the GNU project. . Apache Software Foundation (www.apache.org) Produces the Apache (HTTP) Web server. It also manages related projects, such as SpamAssassin (spam filtering software) and a variety of modules for serving special Web content (perl, SSL, PHP, and so on). . K Desktop Environment (www.kde.org) Develops KDE, one of the two leading desktop environments used with Linux. . GNOME (www.gnome.org) Develops the other leading Linux desktop environment (used as the default desktop for Red Hat Linux systems). . X.org (www.x.org) and XFree86 (www.xfree86.org) These two organizations provide different implementations of the X Window System graphical desktop framework software. . Internet Systems Consortium (www.isc.org) Develops several major open source software projects related to the Internet. These include Bind (domain name system server), INN (InterNetNews news server), and DHCP (dynamic host configuration protocol). Linux User Groups A good way to learn more about Linux and become more a part of the Linux community is to hook up with a Linux User Group (LUG). LUGs tend to come and go, so you might have to do some work to track one down in your area. Here are some places to start your search: . Google (www.google.com/linux) I found both of the LUGs I ve been associated with by using Google to search for the word Linux and the city closest to where I was living. . Linux Meetup Groups (linux.meetup.com) Enter your ZIP Code to search for the nearest LUG in your area.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

828 Appendix B . Entering the Linux Community (Web hosting services)

828 Appendix B . Entering the Linux Community on Mac hardware. The YDL.net site offers some extra services for Yellow Dog Linux users, such as personal e-mail accounts and Web space. . Gentoo (www.gentoo.org) The center for the very active Gentoo community. The site contains a wealth of information about Gentoo and plenty of forums and IRC channels in which to participate. You ll find a solid and growing documentation set to back up the distribution and tons of software packages to try (in the thousands). . Slackware (www.slackware.org) Check the changelogs at this site to get a feel for the latest Slackware developments. Try LinuxPackages (www .linuxpackages.net) for a broader range of information about Slackware. . Linspire (www.linspire.com) Purchase a computer running Linspire from this site, or just buy the boxed set. Linspire offers a Live CD version you can try out for free. . Mandriva (www.mandrivalinux.com) Formed from the merger of Mandrake Linux and Connectiva Linux, the Mandriva Linux Web site gives visitors a variety of Linux products, services, and support. Companies and Groups Supporting Linux Some companies and organizations make important contributions to Linux and open source software without producing their own Linux distribution. Here are some of the most prominent ones: . VA Software (www.vasoftware.com) With its Open Source Technology Group (OSTG), VA Software manages many of the premier open source sites on the Web. It maintains open source development sites Freshmeat (www. freshmeat.net) and SourceForge (www.sourceforge.net). It also maintains information technology sites, such as Slashdot (www.slashdot.org), NewsForge (www.newsforge.com), Linux.com (www.linux.com), and IT Manager s Journal (www.itmanagersjournal.com). . IBM (www.ibm.com/linux) Because IBM has taken on the lion s share of lawsuits against Linux and done a lot to further Linux, especially in the enterprise area, it deserves a mention here. There are many good resources for Linux at IBM s Web site, including some excellent white papers covering Linux in business. . Ibiblio (www.ibiblio.org) Contains a massive archive of Linux software and documentation (www.ibiblio.org/pub/linux).
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Web page design – Appendix B . Entering the Linux Community 827

Appendix B . Entering the Linux Community 827 Linux Distributions Every major Linux distribution has a Web site that provides information about how to get it and use it. If you haven t chosen a distribution yet, here are some sites that can help you evaluate, find, and get a Linux distribution that interests you: . Distrowatch (www.distrowatch.com) Contains information about a few hundred different Linux distributions. The site provides an easy way to find out about different distributions, and then simply connect to the distribution s home page, download site, or related forums. . LinuxISO.org (www.linuxiso.org) Provides information about Linux distributions and how to get them. Also tells you about downloading, verifying, and burning your own CDs from ISO images. . LWN.net Linux Distributions (lwn.net/Distributions) If you want to read succinct descriptions of more than 400 Linux distributions on one page, this is the place to go. Here are key sites associated with Linux distributions covered in this book: . Fedora (fedora.redhat.com) Community-driven Linux, supported by Red Hat. In the past year, Red Hat, Inc. has designated FedoraForum.org as the official Forum site for Fedora. The project itself is transitioning from the Red Hat Web site to http://fedoraproject.org. Check the Fedora Legacy Project (http://fedoralegacy.org) for long-term support issues. Look to Fedora Extras (www.fedora.us) and Livna.org (rpm.livna.org) for downloads of extra Fedora software. . Red Hat Enterprise Linux (www.redhat.com) Check the main Red Hat Web site for information on commercial Linux products. . Debian GNU/Linux (www.debian.org) Get news, documentation, support, and download information about Debian. Try the Debian news site (www.us .debian.org/News/) for the latest news articles on Debian. . SUSE (www.novell.com/linux/suse) Get product and support information from this project s site. The Novell site also provides information about Novell s own Linux offerings. The community supported version of SUSE (called openSUSE) also has a Web site (http://www.opensuse.org). . Knoppix (www.knopper.net/knoppix/index-en.html) The official KNOPPIX page on its creator s (Klaus Knopper s) Web site. An English forum is at www.knoppix.net, and a German forum at www.linuxtag.org/forum. . Yellow Dog (www.yellowdoglinux.com) From this site, sponsored by Terra Soft Solutions, you can purchase Yellow Dog Linux on CDs or get it pre-installed
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.