YUI 3.x Home -

YUI Library Examples: Sortable List Utility: Multiple Sortable Lists - Outer Join

Sortable List Utility: Multiple Sortable Lists - Outer Join

This example makes multiple sortable lists that are outer joined together. In the example below you will see 2 lists. Both lists are sortable, but List #1 can move its items into List #2 and they become sortable. However, List #2 can not move its items into List #1.

List #1

  • Item #1.1
  • Item #1.2
  • Item #1.3
  • Item #1.4
  • Item #1.5
  • Item #1.6
  • Item #1.7
  • Item #1.8
  • Item #1.9
  • Item #1.10

List #2

  • Item #2.1
  • Item #2.2
  • Item #2.3
  • Item #2.4
  • Item #2.5
  • Item #2.6
  • Item #2.7
  • Item #2.8
  • Item #2.9
  • Item #2.10

Note: When using an outer or inner joined list, you must pick a moveType of 'move' or 'copy', the default 'swap' won't give you the results you expect.

This example assumes that you have seen the Multiple Sortable Lists - Full Join example and continues from there.

Joining the lists

After creating the Sortable lists, we will do an outer join. Joining list1 with list2 on the outside. But first we need to choose a moveType. The moveType will determine how an item is moved from one list to another: swap, move or copy. For this example we are using the move type.

  1. var list1 = new Y.Sortable({
  2. container: '#list1',
  3. nodes: 'li',
  4. opacity: '.1',
  5. moveType: 'move' //This is important
  6. });
    var list1 = new Y.Sortable({
        container: '#list1',
        nodes: 'li',
        opacity: '.1',
        moveType: 'move' //This is important
    });
  1. list1.join(list2, 'outer');
    list1.join(list2, 'outer');

Full Example Source

  1. YUI().use('dd-constrain', 'sortable', function(Y) {
  2. var list1 = new Y.Sortable({
  3. container: '#list1',
  4. nodes: 'li',
  5. opacity: '.1',
  6. moveType: 'move'
  7. });
  8. list1.delegate.dd.plug(Y.Plugin.DDConstrained, {
  9. constrain2node: '#demo'
  10. });
  11.  
  12. var list2 = new Y.Sortable({
  13. container: '#list2',
  14. nodes: 'li',
  15. opacity: '.1'
  16. });
  17. list2.delegate.dd.plug(Y.Plugin.DDConstrained, {
  18. constrain2node: '#demo'
  19. });
  20.  
  21.  
  22. list1.join(list2, 'outer');
  23. });
YUI().use('dd-constrain', 'sortable', function(Y) {
    var list1 = new Y.Sortable({
        container: '#list1',
        nodes: 'li',
        opacity: '.1',
        moveType: 'move'
    });
    list1.delegate.dd.plug(Y.Plugin.DDConstrained, {
        constrain2node: '#demo'
    });
 
    var list2 = new Y.Sortable({
        container: '#list2',
        nodes: 'li',
        opacity: '.1'
    });
    list2.delegate.dd.plug(Y.Plugin.DDConstrained, {
        constrain2node: '#demo'
    });
 
 
    list1.join(list2, 'outer');
});

Copyright © 2010 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings