The jQuery UI sortable widget allows the user to pick an item up, and drop it in another location. It's kinda like the draggable widget and in fact, uses the draggable widget to implement the draggable behaviour. A key difference, however, is that sortable will shuffle the other items around as the item is dragged, and after it's dropped. It re-sorts the items. The only style changes applied to the item that's being moved is it's position. We can use some fancy 3D CSS to make the item stand out even more when it's being dragged.
Tuesday, July 8, 2014
Tuesday, April 1, 2014
jQuery UI: Containing Sortables
The sortable widget has an option called containment
. This means that when the user picks up a sortable item with the mouse, the movement is constrained by this option value. By default, there is no such restriction in place — the user is free to move the item around on the page. This can lead to problems in understanding what they're actually supposed to do with the item. For example, basic sortables mean taking an li
element, and moving it around in the parent ul
element. If the user can drag the element anywhere on the page, and there's nowhere to drop it, that's not an ideal experience.
Tuesday, January 28, 2014
A Sortable Storyboard
The sortable widget can do a lot. And with very little effort, despite the numerous options available. For example, you can use it to implement a basic scrum storyboard. This demo isn't necessarily unique to scrum, sorting elements between categorized columns has many uses. The really interesting thing about this code is how little of it there is. Once you have the markup structured in a logical and sane way, you can write a little CSS to get your basic alignment right. Then you let the jQuery UI theme framework do the heavy lifting. Your only job is to then is to add classes to the elements. The sortable interaction widget handles the dragging of stories and defects between the various states, or, the columns.
Thursday, November 21, 2013
jQuery UI: Sorting Between Tables
connectWith
. This option let's us connect our sortable instances with other sortables. That is, not only can you drag elements to sort them within the primary sortable, but you can drag them into the connected sortable. This setup can work bidirectionally too — you can drag the item back to the original sortable after it's been moved out. This drag and drop behavior, I've found, to be especially useful for connecting table data.