user1896653
user1896653

Reputation: 3327

How to make jQuery sortable plugin working with list

I am trying to put this jQuery sortable plugin into my bootstrap list-group-item. I just want to put normal drag-drop/sortable option, no effect/animation. That's why, I just made my code like this:

HTML:

<ul class="list-group item-list">
   <li class="list-group-item">Item 1</li>
   <li class="list-group-item">Item 2</li>
   <li class="list-group-item">Item 3</li>
</ul>

<ul class="list-group item-list">

</ul>

jQuery:

$('.item-list').sortable();

But, it could not drop item from first ul.item-list to second ul.item-list! How to make it working?

Fiddle work

Upvotes: 1

Views: 1878

Answers (1)

vm2013
vm2013

Reputation: 414

It looks like you need more than just calling .sortable()?

This example seem to do what you want to do, they use ol rather than ul tags with li items

http://johnny.github.io/jquery-sortable/#connected

Then simply "show code" to get the example

*******Update*********

Working code:

$('.item-list').sortable({
    group: 'list-group',
    pullPlaceholder: false,
});

Fiddle

Upvotes: 2

Related Questions