Book Image

jQuery UI 1.7: The User Interface Library for jQuery

Book Image

jQuery UI 1.7: The User Interface Library for jQuery

Overview of this book

Modern web application user interface design requires rapid development and proven results. jQuery UI, a trusted suite of official plug-ins for the jQuery JavaScript library, gives you a solid platform on which to build rich and engaging interfaces with maximum compatibility and stability, and minimum time and effort. jQuery UI has a series of ready-made, great-looking user interface widgets and a comprehensive set of core interaction helpers designed to be implemented in a consistent and developer-friendly way. With all this, the amount of code that you need to write personally to take a project from conception to completion is drastically reduced. Specially revised for version 1.7 of jQuery UI, this book has been written to maximize your experience with the library by breaking down each component and walking you through examples that progressively build upon your knowledge, taking you from beginner to advanced usage in a series of easy-to-follow steps. In this book, you'll learn how each component can be initialized in a basic default implementation and then see how easy it is to customize its appearance and configure its behavior to tailor it to the requirements of your application. You'll look at the configuration options and the methods exposed by each component's API to see how these can be used to bring out the best of the library. Events play a key role in any modern web application if it is to meet the expected minimum requirements of interactivity and responsiveness, and each chapter will show you the custom events fired by the component covered and how these events can be intercepted and acted upon.
Table of Contents (19 chapters)
jQuery UI 1.7
Credits
About the Author
About the Reviewers
Preface
Index

Preface

Modern web application user interface design requires rapid development and proven results. jQuery UI, a trusted suite of official plugins for the jQuery JavaScript library, gives you a solid platform on which to build rich and engaging interfaces with maximum compatibility, stability, and a minimum of time and effort.

jQuery UI has a series of ready-made, great looking user interface widgets, and a comprehensive set of core interaction helpers designed to be implemented in a consistent and developer-friendly way. With all this, the amount of code that you need to write personally to take a project from conception to completion is drastically reduced.

Specially revised for version 1.7 of jQuery, this book has been written to maximize your experience with the library by breaking down each component and walking you through examples that progressively build upon your knowledge, taking you from beginner to advanced usage in a series of easy-to-follow steps.

In this book, you'll learn how each component can be initialized in a basic default implementation and then see how easy it is to customize its appearance and configure its behavior to tailor it to the requirements of your application. You'll look at the configuration options and the methods exposed by each component's API to see how these can be used to bring out the best of the library.

Events play a key role in any modern web application if it is to meet the expected minimum requirements of interactivity and responsiveness, and each chapter will show you the custom events fired by the component covered and how these events can be intercepted and acted upon.

What this book covers

Chapter 1, Introducing jQuery UI, gives a general overview and introduction to jQuery UI. You find out exactly what the library is, where it can be downloaded from, and where resources for it can be found. We look at the freedom the license gives you to use the library and how the API has been simplified to give the components a consistent and easy to use programming model.

In Chapter 2, The CSS Framework, we look in details at the extensive CSS framework that provides a rich environment for integrated theming via ThemeRoller, or allows developers to easily supply their own custom themes or skins.

In Chapter 3, Tabs, we look at the tabs component; a simple but effective means of presenting structured content in an engaging and interactive widget.

Chapter 4, The Accordion Widget, looks at the accordion widget, another component dedicated to the effective display of content. Highly engaging and interactive, the accordion makes a valuable addition to any web page and its API is exposed in full to show exactly how it can be used.

In Chapter 5, The Dialog, we focus on the dialog widget. The dialog behaves in the same way as a standard browser alert, but it does so in a much less intrusive and more visitor-friendly manner. We look at how it can be configured and controlled to provide maximum benefit and appeal.

Chapter 6, Slider, looks at the slider widget that provides a less commonly used, but no less valuable user interface tool for collecting input from your visitors. We look closely at its API throughout this chapter to see the variety of ways that in which it can be implemented.

In Chapter 7, Datepicker, we look at the datepicker. This component packs a huge amount of functionality into an attractive and highly usable tool, allowing your visitors to effortlessly select dates. We look at the wide range of configurations that its API makes possible as well as seeing how easy common tasks such as skinning and localization are made.

In Chapter 8, Progressbar, we look at the new progressbar widget; examining its compact API and seeing a number of ways in which it can be put to good use in our web applications.

In Chapter 9, Drag and Drop, we begin looking at the low-level interaction helpers, tackling first the related drag-and-droppable components. We look at how they can be implemented individually and how they can be used together for maximum effect.

Chapter 10, Resizing, looks at the resizing component and how it is used with the dialog widget from earlier in the book. We see how it can be applied to any element on the page to allow it be resized in a smooth and attractive way.

In Chapter 11, Selecting, we look at the selectable component, which allows us add behavior to elements on the page and allow them be selected individually or as a group. We see that this is one component that really brings the desktop and the browser together as application platforms.

Chapter 12, Sorting, looks at the final interaction helper—the sortable component. This is an especially effective component that allows you to create lists on a page that can be reordered by dragging items to a new position on the list. This is another component that can really help you to add a high level of professionalism and interactivity to your site with a minimum of effort.

Chapter 13, UI Effects, is dedicated solely to the special effects that are included with the library. We look at an array of different effects that allow you to show, hide, move, and jiggle elements in a variety of attractive and appealing animations. There is no 'fun with' section at the end of this chapter; the whole chapter is a 'fun with' section.

What you need for this book

  • A copy of the latest jQuery UI full build (1.7.2 at the time of writing)

  • A code or text editor

  • A browser

  • The code download for the book

Who this book is for

This book is for developers who want to quickly and easily build engaging, highly interactive interfaces for their web applications, or less commonly, for embedded applications.

Nokia was the first mobile phone company to announce that they were adopting jQuery to power parts of their cell phone operating system. I'm sure that by the time this book is published there will be more companies adapting the library for their own needs, and wherever jQuery goes, jQuery UI can follow.

People who are comfortable with HTML, JavaScript, and CSS along with having at least some experience with jQuery itself will get the most benefit from what this book has to offer. However, no prior knowledge of the UI library itself is required.

Consider the following code:

$("#myEl").click(function() { 
  $("<p>").attr("id", "new").css({
    color:"#000000"
  }).appendTo("#target");
)};

If you cannot immediately see, and completely understand, what this simple code snippet does, you would probably get more from this book after first learning about jQuery itself. Consider reading Karl Swedberg and Jonathan Chaffer's excellent Learning jQuery 1.3, also by Packt Publishing, or visit http://www.learningjquery.com for an excellent foundation in jQuery, and then come back to this book.

Each jQuery UI specific method or property that we work with will be fully covered in the explanatory text that accompanies each code example, and where it is practical, some of the standard jQuery code will also be discussed. CSS and HTML will take a back seat and be covered very briefly, if at all, unless it is completely central to the discussion at hand.

Basic concepts of using jQuery itself won't be covered. Therefore, you should already be familiar with advanced DOM traversal and manipulation, attribute and style getting and setting, and making and handling AJAX calls. You should be comfortable with the programming constructs exposed by jQuery such as method chaining, using JavaScript objects, and working with callback functions.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

[default]
var pickerOpts = {
  changeMonth: true,
  changeYear: true,
  yearRange: "-25:+25"
};

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
var pickerOpts = {
  minDate: new Date(),
};

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/9720_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.