Book Image

jQuery UI Cookbook

By : Adam Boduch
Book Image

jQuery UI Cookbook

By: Adam Boduch

Overview of this book

jQuery UI is the quintessential framework for creating professional user interfaces. While jQuery core lays the foundation for interaction with the DOM and handling events, jQuery UI fills in the user interaction gap. This book will give you a huge productivity boost out of the box with jQuery UI, and help you understand the framework, inside and out."jQuery UI Cookbook" provides you with practical recipes featuring in-depth coverage of every widget in the framework, including how to address limitations that impact your everyday development activities with these widgets. You'll get a better idea of the big picture – how the framework is composed, how the widgets relate to one another, and how to build on those patterns.Be it a minor tweak on the visual design of a progress bar or a fundamental change in a widget to meet your needs, "jQuery UI Cookbook" covers scenarios both big and small. You can show reminders as tooltips, apply a variety of effects to the menu widget, and start interactions between the dialog widget and API data using deferred objects. These and many more interesting tasks are covered in this book, which can be done with smooth learning and great understanding. You will see how button widgets can fill the width of their containing element, making the layout more consistent. Tabs can be sorted and moved between widgets. You will learn how to do all these things within the context of the big picture, by finding out why the components work the way they do, making you well-versed in jQuery UI.
Table of Contents (19 chapters)
jQuery UI Cookbook
About the Author
About the Reviewers


Creating user experiences that excite users is a fun and rewarding job. You're essentially improving the lives of many people. Most UI developers have their eye on the finish line, seeing their product put to use. The faster we get to that finish line without sacrificing quality, the better. The tools we use to help get us there can make all the difference in the world.

Part of what makes the jQuery Framework so popular among developers, the "write less, do more" mantra, materializes in jQuery UI as well. The modern versions of HTML and CSS standards have the tools required for assembling a robust, responsive user interface. Where this idea falls apart—browser inconsistencies and lack of development conventions and patterns across projects—jQuery UI steps in. The goal of jQuery UI isn't to reinvent the way we write web applications, but rather, to fill in gaps and progressively enhance existing browser components.

Like any framework, jQuery UI isn't for everyone, nor is it perfect for those that do use it. The framework embraces this fact, and provides extensibility mechanisms for most situations you might find yourself in. My goal with this book is to share with you some experiences I've had with jQuery UI widgets. I've extended where possible, and hacked where necessary. I'm sure you'll find the majority of the recipes in this book useful, no matter what kind of application you're building.

What this book covers

Chapter 1, Creating Accordions, helps you learn how to drag-and-drop between accordion widgets. In addition, you'll learn how to extend the accordion theme.

Chapter 2, Including Autocompletes, explains the autocomplete widget that shows how to use multiple data sources. Turning select options into autocomplete widgets, and remote data source filtering are covered too.

Chapter 3, Crafting Buttons, explains about modifying buttons for our application. Buttons can be simple, modifying text and icon options. Or, buttons can be more involved, such as when working with button sets. We'll look into spacing issues, and how to apply effects.

Chapter 4, Developing Datepickers, talks about datepicker, which is the most widely-used widget, yet the most under-utilized. We'll uncover some potentials of the widget by using some techniques to better integrate datepicker into your application.

Chapter 5, Adding Dialogs, discusses dialog widgets, which often rely on API data. We'll look into loading data and dialog display issues. We also cover changing the dialog title bar, and applying effects to the widget.

Chapter 6, Making Menus, helps you learn how to make sortable menu items. We'll address theme concerns and highlighting the active menu item as well.

Chapter 7, Progress Bars, shows how to add labels to progress bars. We'll also extend the progress bar to make a loading widget.

Chapter 8, Using Sliders, talks about the slider widget that doesn't display step increments. Here, you will extend the widget to provide this capability. We also look into changing the visual display of the slider handle.

Chapter 9, Using Spinners, explains spinners, which are often used in forms. So we deal with formatting spinner values for local currencies and dates in this chapter. We'll also look into addressing theme concerns with the widget.

Chapter 10, Using Tabs, introduces some new techniques in working with tabs, that is, using each tab as a plain URL link. We also cover some more advanced tab navigation usage—dynamic loading and reading the browser hash.

Chapter 11, Using Tooltips, explains tooltips, which can be applied to just about anything on the page. In this chapter, we'll show you how to apply effects to the tooltip, change the tooltip state, and apply tooltips to selected text.

Chapter 12, Widgets and More!, talks about widgets, which don't exist in a vacuum. They're part of a larger application. This chapter covers the bigger jQuery UI development picture. This includes building a widget from scratch, building your own development tools, and working with Backbone.

What you need for this book

You will require the following:

  • A modern web browser for running the examples.

  • A text-editor for reading along and tweaking the examples.

  • All JavaScript dependencies included in the examples download.

  • Python (optional); some examples require a web server, and use the built-in Python web server in the examples. The examples could use any web server with the appropriate adjustments.

Who this book is for

This book is for the jQuery UI developer looking to improve their existing applications, extract ideas for their new application, or to better understand the overall widget architecture. The reader should at least have a rudimentary understanding of what jQuery UI is, and have written some code that uses jQuery UI. The recipes in this book are targeted at the intermediate jQuery UI developer. Depending on your needs, each recipe is self-contained enough to be useful on its own, but connected enough to guide you to others.


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: "In this scenario, we're better off just changing the default dateFormat value to something our application uses throughout."

A block of code is set as follows:

$(function() {
    $( ".calendar" ).datepicker();

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 on the no icons link would result in the button icons being removed, and replaced with their text."


Warnings or important notes appear in a box like this.


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 e-mail to , and mention the book title via the subject of your message.

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

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.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


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 improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


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 website 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.


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.