Question

I have a draggable object, but N sortable objects on screen, actually, they are nested. Not quite like a unordered list of unordered lists, but that is a solid example.

Based on what I am hovering over with the draggable object, I'd like to set the corresponding sortable list that I wish to append to. I was thinking of something like:

$(_d).draggable({
    helper: "clone",
    drag: function(){
       //get position.
       //compare position with all container dimensions.
       //if match,  $(this).draggable("options", "connectToSortable", "selector-for-particular-sortable
    },
    stop: function(){},
});

/*dynamic, so i cant use connectToSortable on all of them.*/
$(_a).sortable();
$(_b).sortable();
$(_c).sortable();

I just feel that it is time consuming to drag and scan all container objects on the screen. I wasnt sure if there were others who did something similar.

My thoughts stem from both a project i am looking at, while also looking at : jQuery UI draggable element dropped into sortable

Était-ce utile?

La solution

If you can assign a class, or know a set of classes which represent a sortable object, you can literally add them into the connectToSortable object.

See example: http://jsfiddle.net/4UR8X/

$(item).draggable({helper:'clone', connecToSortable:'.containers'});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top