Reputation: 23
I need to create a drag and drop feature for a page on my website that allows the user (once logged in) to drag a picture that they like or favorited into a 'closet' that they make. I've been trying Jquery draggable but it's not how I want it to work.
It's basically like when you try to drag a file into recycle bin.
What are the basic approaches to this? I already have my images dynamically pulled (when a user 'likes' a picture, it'll pop up in the closet page). All I need is to have this drag and drop functionality to work.
Upvotes: 1
Views: 386
Reputation: 1007
what you need is to configure your draggable object to revert in invalid and your droppable only accept a draggable object then on drop you can execute a function and do whatever you want,
<div id="my-draggable"></div>
<div id="my-droppable"></div>
<script>
$("#my-draggable").draggable({ revert: "invalid" });
$("#my-droppable").droppable({
accept: "#my-draggable",
drop: function( event, ui ) {
//do whatever you want in here
}
});
Upvotes: 1