In JQuery UI, I have a draggable, It have an option connectToSortable as below:
$("#social li").draggable({
connectToSortable: '#form_builder_sortable',
helper:'clone',
revert:true
});
'#form_builder_sortable' is a sortable as below:
$("#form_builder_sortable").sortable();
I want 1 draggable list connect to multiple sortable list, such as:
$("#social li").draggable(
{
connectToSortable: '#form_builder_sortable, #form_builder_sortable_sample',
helper:'clone',
revert:true
});
Have you got any solutions or suggestion to do as my requirement? Thanks a lot
The connectToSortable
option accepts a selector and a selector can specify any number of lists.
Please see following example:
Draggable list
<ul>
<li class="draggable ui-state-highlight">Drag me down</li>
</ul>
Mulitiple list
<ul id="form_builder_sortable" class="sortable">
<li class="ui-state-default draggable">Item 1</li>
<li class="ui-state-default draggable">Item 2</li>
<li class="ui-state-default draggable">Item 3</li>
</ul>
<ul id="form_builder_sortable_sample" class="sortable">
<li class="ui-state-default draggable">Item 1</li>
<li class="ui-state-default draggable">Item 2</li>
<li class="ui-state-default draggable">Item 3</li>
<li class="ui-state-default draggable">Item 4</li>
</ul>
I gave them same class class="sortable"
because I want drag draggable list to both of them. Finally I can use code below for drag it:
$(".sortable").sortable();
$(".draggable").draggable({
connectToSortable: '.sortable', // Selector selects lists that have sortable class
helper: 'clone'
});
Online demo (fiddle)