Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery-UI Draggable and Sortable

So I've been working with this example: http://jqueryui.com/demos/draggable/#sortable and I've accomplished it on my product. However I want to make two significant changes.

  1. I don't want the second list(toList in my example) to be sortable on it's own. I only want it to accept items from the first list(fromList in my example).

  2. When a user drags an item from the first list(fromList) and drops it into the second list(toList) I want that item to be forced to the bottom.

Suggestions? Here is a working fiddle of what I have so far. http://jsfiddle.net/CrtFD/

like image 456
Ryan Mulready Avatar asked Sep 03 '26 10:09

Ryan Mulready


1 Answers

Try using a droppable for your toList:

EDIT: Per comments below:

http://jsfiddle.net/abzYK/

jQuery(document).ready(function(){
    jQuery("#fromList li").draggable('destroy').draggable({
        connectToSortable: "#toList",
        revert: "invalid",
        containment: '#equipCont',
        helper: function(e, ui) {
            return jQuery(this).clone().css('width', jQuery(this).width());
        }
    });
    jQuery("#toList").droppable('destroy').droppable({
        drop: function(e, ui) {
            var dragClone = jQuery(ui.draggable).clone();
            jQuery("#toList").append(dragClone);
        }
    });
    jQuery("ul, li").disableSelection();
});
​
like image 105
fehays Avatar answered Sep 04 '26 23:09

fehays



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!