index.mustache revision cf8d258dad6b67aaddce8ebdc54e9ae70e7b2b9c
0N/A<p> The Sortable Utility allows you to create a sortable list from a container and a group of children. It also allows you to join lists together in various ways.</p>
<p>To turn this into a sortable list, you just need to create the `Sortable` object and tell it the `container` and the `nodes`.</p>
<p>The `nodes` can be any selector string that matches a child of the `container`. For performance reasons you will want to make the `container` an element that is as close to the `nodes` as possible. The farther away in the DOM the `container` is from the `nodes` the worse the performance will be.</p>
var sortable = new Y.Sortable({
<p><strong>Note:</strong> `Sortable` does not auto find your drop target items, if you change the `nodes` under the hood (add or remove) you need to call `sortable.sync()` to manage them.</p>
<p>Sortable uses `DD.Delegate` under the hood to handle the Drag and Drop operations. It sets itself as the `bubbleTarget` of the `Delegate` instance, so all `DD`-related events are bubbled to it.</p>
<p>For more information on `DD` related events, see the <a href="../dd/#events">events section on the Drag and Drop page</a>.</p>
<p>By default, a `Sortable` list can only interact with itself; you can't drag from one `Sortable` list to another. But a `Sortable` instance can be configured to be joined with another `Sortable` instance.</p>
<p>There are four ways a `Sortable` list can be joined: `inner`, `outer`, `full` and `none` (`none` is the default).</p>
<td>Items in the joined list can be moved into the main list but items in the main list can not be moved to the joined list.</td>
<td>Items in the main list can be moved into the joined list but items in the joined list can not be moved to the main list.</td>
var sortable1 = new Y.Sortable({
var sortable2 = new Y.Sortable({
sortable1.join(sortable2, 'full');
var sortable1 = new Y.Sortable({
var sortable2 = new Y.Sortable({
var sortable3 = new Y.Sortable({
sortable1.join(sortable2, 'inner');
sortable2.join(sortable3, 'outer');
sortable3.join(sortable1, 'full');
sortable3.join(sortable2, 'full');
<p>The `DD.Delegate` object bound to a `Sortable` instance is exposed to allow you to easily attach plugins to a `Sortable` instance.</p>
<p>The `Sortable` instance has a `delegate` namespace, which is a reference to the internal `DD.Delegate` instance.</p>
var sortable = new Y.Sortable({
sortable.delegate.dd.plug(SomeDDPlugin);