Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery UI Examples - Sortable (Sortable)

jQuery UI Examples - Sortable (Sortable)

Reorder elements in a list or grid using the mouse.

For more details about the sortable interaction, see the API documentation Sortable Widget。

Default functionality

Enable sortable functionality on any DOM element. Click and drag an element with the mouse to a new position in the list, and the other items adjust automatically. By default, sortable items share the same class. draggable attribute.









  

  jQuery UI 排序(Sortable) - 默认功能

  

  

  

  

  

  





 

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 6
  • Item 7

Concatenating Lists

By passing a selector to the connectWith option, you can sort items from one list into another and vice versa. The easiest way is to group all related lists with a CSS class and pass that class to the sortable function (for example,connectWith: '.myclass')。









  

  jQuery UI 排序(Sortable) - 连接列表

  

  

  

  

  

  





 

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5

Tabbed connected lists

Sort items from one list into another and vice versa by dropping list items into the appropriate tab at the top.









  

  jQuery UI 排序(Sortable) - 标签页连接列表

  

  

  

  

  

  





 

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5

Delayed start

Prevent accidental sorting with a time delay and a distance delay. Use the delay option to set the number of milliseconds an item must be dragged before sorting starts. Use the distance option to set the number of pixels an item must be dragged before sorting starts.









  

  jQuery UI 排序(Sortable) - 延迟开始

  

  

  

  

  

  





 

时间延迟 300ms:

  • Item 1
  • Item 2
  • Item 3
  • Item 4

距离延迟 15px:

  • Item 1
  • Item 2
  • Item 3
  • Item 4

Display as a grid

Make the sortable items display as a grid, using CSS so they have the same size and are floated.









  

  jQuery UI 排序(Sortable) - 显示为网格

  

  

  

  

  

  





 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

Placeholder

When dragging a sortable item to a new position, the other items make room for it. Pass a placeholder class to the option to define the appearance of the visual empty space. Use the boolean forcePlaceholderSize option to set the size of the placeholder.









  

  jQuery UI 排序(Sortable) - 放置占位符

  

  

  

  

  

  





 

  • Item 1
  • Item 2
  • Item 3
  • Item 4
  • Item 5
  • Item 6
  • Item 7

Handling an empty list

By setting the `` option to false, prevent all items from one list from being dropped into a separate empty list. By default, sortable items can be dropped into empty lists.









  

  jQuery UI 排序(Sortable) - 处理空列表

  

  

  

  

  

  





 

  • 可被放置到..
  • ..一个空列表中
  • Item 3
  • Item 4
  • Item 5
  • 不可被放置到..
  • ..一个空列表中
  • Item 3
  • Item 4
  • Item 5

Include/exclude items

Specify which items are sortable by passing a items jQuery selector to the option. Items not matched are not sortable, nor are they valid drop targets for sortable items.

If you only want to prevent specific items from being sorted, pass a cancel jQuery selector to the option. Canceled items are still valid sort targets for other items.









  

  jQuery UI 排序(Sortable) - 包含/排除条目

  

  

  

  

  

  





 

指定哪个条目是 sortable:

  • Item 1
  • (我不是 sortable 或者一个放置目标)
  • (我不是 sortable 或者一个放置目标)
  • Item 4

取消排序(但作为放置目标):

  • Item 1
  • (我不是 sortable)
  • (我不是 sortable)
  • Item 4

Portlets (Portlets)

Enable portlets (styled divs) as sortable, and use the connectWith option to allow sorting between columns.









  

  jQuery UI 排序(Sortable) - 门户组件(Portlets)

  

  

  

  

  

  





 

订阅
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
新闻
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
购物
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
链接
Lorem ipsum dolor sit amet, consectetuer adipiscing elit
图像
Lorem ipsum dolor sit amet, consectetuer adipiscing elit