I
I
Ilya Chernichkin2011-09-01 09:16:09
JavaScript
Ilya Chernichkin, 2011-09-01 09:16:09

Select and drag multiple list items?

Good afternoon, the following task arose and the problem is It is
necessary to create a drag-n-drop list with the ability to select several positions and move them.
I used jquery ui sortable, but the maximum I achieved was that when selecting the elements are fastened, but only one element moves ((

Here is my
HTML code:

  • 4.2.1.3.t JavaScript :
    _
    _



    $(document).ready(function(){ <br/>
    <br/>
    $(function() {<br/>
     <br/>
     $(&quot;#test-list&quot;).sortable({<br/>
     placeholder: 'ui-state-highlight',<br/>
    <br/>
    helper: function(){ <br/>
     <br/>
     var selected = $('#test-list input:checked').parents('li'); <br/>
     if (selected.length === 0) { <br/>
     selected = $(this); <br/>
     } <br/>
     var container = $('&lt;div/&gt;').attr('id', 'draggingContainer'); <br/>
     container.append(selected.clone()); <br/>
     return container; <br/>
     }<br/>
     });<br/>
     $(&quot;#test-list&quot;).disableSelection();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dialog, 2011-09-01
@Dialog

$('#test-list input:checked').parents('li').each(function(){
//create and populate an array of parents
});
// then in a loop we add them to the container ...
dig in this direction, for debugging, be sure to use firebug or the console in chrome

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question