JQuery draggable - allow containment to multiple containers?
I'd lik开发者_如何学JAVAe to allow users to drag an element from one container to another while still being constrained from being able to drag the element outside of either of those two containers. I have everything working perfectly except the part where they can drag to another container.
View code and result on JSFiddle.net
I thought this post seemed like the answer but it doesn't appear to work for me.
I added a jQuery UI droppable
to your fiddle. With a little bit of tweaking I'm sure you'd be able to get this exactly how you want it.
http://jsfiddle.net/U2nKh/20/
just add these lines inside your draggable function like this:
$("#drop").draggable({revert: 'invalid',
start: function(){
currentParent = $(this).parent().attr('id');
}});
精彩评论