This question related to jQuery's UI.
Can anybody provide an example the does the following:
- Container A is sortable and droppable
- Any element can be dragged into Container A and then sorted.
- Any element can be dragged out of Container A and then simply become draggable around the page.
- Container A is also draggable around the page
This is what I have so far:
$(function() {
$("#sortable").sortable().droppable();
$("#sortable").disableSelection();
$("#drop").droppable({
accept: "#sortable li",
drop: function (evt, ui) {
var $destination = $(this);
ui.draggable.appendTo( $destination );
}
}).draggable();
});
I created a fiddle here: http://jsfiddle.net/eEJHb/1/
Problems that I'm running into: A) I can't get the sortable to drop into the container B) Once in the container, I need the element to be draggable back to the sortable list
Thanks for your help!
UPDATE ** Part of my problem lied in option "connectWith". It simply wasn't working. Instead, I used the option "connectToSortable" (as an option in the draggable) and I was able to get the sortable and draggable working together.
I had the same problem until I find this
You can use the Interactions from jquery-ui. It provides dragable and sortable interactions.
Here are examples.
I would suggest you check out this documentation:
http://jqueryui.com/sortable/#connect-lists
http://jqueryui.com/draggable/#sortable
and the answers to these questions:
Getting jQuery sortable, droppable and draggable to work together
jQuery-UI Draggable and Sortable