开发者

JQuery draggable - allow containment to multiple containers?

开发者 https://www.devze.com 2023-04-06 13:00 出处:网络
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

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');
            }});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号