1

How can I make a jquery sortable available in groups ? (that is means that you can also sort it, interchange in other groups as well)

<div class="wpr">
<ul class="items1">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

<ul class="items2">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

js :

$(document).ready(function(){
    Init();
});

function Init(){
    $( ".items1" ).sortable();
}

Demo

I just want to add, that I also have a draggable and droppable in this project. , which means that the droppable is also a sortable in those groups..

1 Answer 1

2

Use this....

$( ".items1" ).sortable({
        connectWith: '.items2'
    });

Or Use this..

<ul id="items1" class="items">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

<ul id="items2" class="items">
    <li>item</li>
    <li>item</li>
    <li>item</li>
    <li>item</li>
</ul>

And the Script::

function Init(){
    $( "#items1" ).sortable({
        connectWith: '.items'
    });
    $( "#items2" ).sortable({
        connectWith: '.items'
    });
}

or

function Init(){
    $( ".items" ).sortable({
        connectWith: '.items'
    });
}

By this you can achieve..

Sign up to request clarification or add additional context in comments.

2 Comments

A slight improvement : $(".items").sortable({ connectWith: ".items" }); fiddle
yup we can do that too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.