Key Takeaways
- After a two and a half year delay, the new 1.9 version of jQuery UI was released, supporting the latest stable release of jQuery all the way back to version 1.6, with many bug fixes and changes.
- The new version includes a complete redesign of the jQuery UI website and the introduction of new Tooltip, Spinner, and Menu widgets, offering increased functionality and user experience.
- The 1.9 release also brings many API redesigns for Accordion, Autocomplete, Dialog, Position, Tabs, and Effects, improving consistency across widgets and better collision detection for the position utility.
- Despite the changes, jQuery UI 1.9 maintains full compatibility with the 1.8 API, ensuring that upgrading to 1.9 should not break any existing pages. Deprecated APIs will be removed in version 1.10.
The State of jQuery UI
I’m excited to tell you about the latest changes, but first let me explain the reasons behind some of them. jQuery UI started as a combination of new and existing plugins collected from different sources. Unfortunately, the downside of this initiative was that each author had his own coding style and design principles, which lead to inconsistency among the plugins and widgets, thus retarding the library’s progress as a whole. Realizing the problem, as of version 1.8, the jQuery UI team tried to change the existing process for building plugins by focusing on more simplified APIs. The main goal for the upcoming 2.0 release is to have a completely redesigned project with a much simpler API, a unified code base, consistency across widgets, better stability, full documentation, and a full test suite for every plugin. And, once the existing plugins have been updated to the new standards, the project will move forward at a much faster pace. Now, let’s discuss the changes in version 1.9.New Web Site
The first thing you will probably notice is that the jQuery UI web site has been completely redesigned with a new look and feel. Besides the new design, which is much wider and cleaner, the API documentation now includes a lot of information that was missing from the old site. The site is still under development, so expect to see even more content in the future.New Widgets
Let’s welcome the new Tooltip, Spinner, and Menu widgets to the library. I won’t provide you with any code examples here because there are plenty of demos already on the jQuery UI web site. Just follow the links below to see the widgets in action.The Tooltip Widget
With the new Tooltip Widget, jQuery UI finally has a built-in tooltip solution. The widget allows you to use static content or remote content loaded via Ajax. You can add custom positioning, and choose what animation to use when the tooltip is shown and/or hidden. Also, with the mouse tracking option set totrue
the tooltip will stick with the mouse pointer until it moves over the element.
The Spinner Widget
When you are dealing with any kind of numeric input, the Spinner Widget can be your best friend. Values can be manipulated with the mouse’s scroll wheel, or via the keyboard. You can spin values by small or by big increments. For example, the up/down arrow keys can spin a value by one, while the page up/down keys spin the value by ten. Also, by using the Globalize plugin you can configure the widget to work with currencies and dates in different locales. Lastly, the overflow option allows you to restrict the spinner to some range. For example, if you set the range from one to five, then anything above five overflows to zero, and vice versa. This is especially useful when working with dates and time.The Menu Widget
The Menu Widget can be used for inline and popup menus, or as a base for building more complex menu systems. For example, you can create nested menus with custom positioning. Speaking of menus, two more widgets, Selectmenu and Menubar, are planned for the 1.10 release. You can see the Roadmap for details.API Redesigns
As previously mentioned, jQuery UI is being refactored to become more consistent and compact. Because of this, many API changes have been made in the new release. Some of the most notable changes are listed below.The Widget Factory
The 1.9 release adds a lot of functionality to the widget factory, especially related to instantiation and inheritance. Widget developers will find lots of new features and improvements. For more details see Widget.Widgets and Effects
jQuery UI 1.9 introduces API redesigns for Accordion, Autocomplete, Dialog, Position, Tabs, and Effects. As a whole, the consistency across widgets has been improved. Each individual widget has also seen some improvements. The accordion widget provides better animation support, the tabs widget has better Ajax support, and the position utility offers better collision detection. All effects files have been renamed to match thejquery.ui.*.js
naming pattern. For example, jquery.effects.*.js
has been renamed to jquery.ui.effect-*.js
. Similarly, jquery.effects.core.js
has been renamed to jquery.ui.effect.js
. If you’re using individual effect files, you’ll need to update your file references accordingly.
Note that only widgets, utilities, and effects are being refactored in version 1.9. All interactions are going to be rewritten for 2.0 so they will be undergoing a different implementation process.
API Compatibility
Although the redesigns introduce changes, 1.9 maintains full compatibility with the 1.8 API. This means that upgrading to 1.9 should not break any existing pages. This is accomplished by rebuilding the 1.8 API on top of the 1.9 API. The default behavior for all 1.9 releases will be to simultaneously use the 1.8 and 1.9 APIs, deferring to the 1.8 API if there is a conflict. Many existing APIs were deprecated in version 1.9. These APIs will be removed in version 1.10. Luckily, you don’t need to wait for the next release to find out if your code will still work once the 1.8 APIs are removed. You can use the$.uiBackCompat
flag to disable all deprecated APIs, allowing you to determine if your code is ready for 1.10. The following example disables deprecated APIs by setting $.uiBackCompat
to false
.
<script src="jquery.js"></script>
<script>$.uiBackCompat = false;</script>
<script src="jquery-ui.js"></script>
Final Words
The Upgrade Guide contains detailed information on upgrading to version 1.9. Don’t be afraid of all these changes. No one is looking forward to refactoring existing code, but the jQuery UI team has put a lot of effort into ensuring a painless transition process.Frequently Asked Questions (FAQs) about jQuery UI 1.9
What are the new features in jQuery UI 1.9?
jQuery UI 1.9 introduces several new features and enhancements. The most significant one is the introduction of the Tooltip widget, which allows developers to create customizable tooltips. Another notable feature is the Menu widget, which provides a versatile menu system with submenus, checkboxes, and radio buttons. The Spinner widget, which allows for number input with increment and decrement buttons, is also a new addition. Lastly, the version also includes improvements to the existing widgets, such as the addition of the “destroy” method and the “refresh” method.
How can I update to jQuery UI 1.9?
To update to jQuery UI 1.9, you need to download the latest version from the official jQuery UI website. Once downloaded, replace your old jQuery UI files with the new ones in your project directory. Remember to update the script source in your HTML files to point to the new jQuery UI files.
What are the benefits of using jQuery UI 1.9?
jQuery UI 1.9 offers several benefits. It provides a set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library. This makes it easier to design and implement complex UI features. The new widgets in version 1.9, such as Tooltip and Menu, provide additional functionality and enhance user experience.
How can I use the new Tooltip widget in jQuery UI 1.9?
The Tooltip widget in jQuery UI 1.9 can be used by selecting an element and calling the tooltip method. You can customize the tooltip by passing options to the tooltip method. For example, you can change the tooltip content, show and hide animations, and events that trigger the tooltip.
What is the purpose of the “destroy” method in jQuery UI 1.9?
The “destroy” method in jQuery UI 1.9 is used to remove any changes made by jQuery UI from the selected elements. This is useful when you want to remove a widget or interaction functionality from an element.
How can I use the new Menu widget in jQuery UI 1.9?
The Menu widget in jQuery UI 1.9 can be used by selecting a list element and calling the menu method. You can customize the menu by passing options to the menu method. For example, you can change the menu items, icons, and events that trigger the menu.
What are the improvements in the existing widgets in jQuery UI 1.9?
jQuery UI 1.9 includes several improvements to the existing widgets. For example, the “destroy” method has been added to all widgets, which removes the widget functionality from an element. The “refresh” method has also been added to some widgets, which updates the widget to reflect any changes in the underlying data.
How can I use the new Spinner widget in jQuery UI 1.9?
The Spinner widget in jQuery UI 1.9 can be used by selecting an input element and calling the spinner method. You can customize the spinner by passing options to the spinner method. For example, you can change the increment and decrement values, and events that trigger the spinner.
What is the purpose of the “refresh” method in jQuery UI 1.9?
The “refresh” method in jQuery UI 1.9 is used to update a widget to reflect any changes in the underlying data. This is useful when the data that a widget is based on changes dynamically.
How can I customize the widgets in jQuery UI 1.9?
The widgets in jQuery UI 1.9 can be customized by passing options to the widget methods. These options allow you to change the behavior and appearance of the widgets. For example, you can change the content of a tooltip, the items in a menu, or the values in a spinner.
I am a web developer/designer from Bulgaria. My favorite web technologies include SVG, HTML, CSS, Tailwind, JavaScript, Node, Vue, and React. When I'm not programming the Web, I love to program my own reality ;)