I am working on a proof of concept that makes use of the jquery ui draggable/droppable.
I am looking for a way to set a variable equal to the index of a div that is dropped into the droppable area. (Say I have divs named "div0", "div1", "div2", etc...)
So imagine the code would look something like this:
<div id="div0" class="draggableDiv">some cotent</div>
<div id="div1" class="draggableDiv">more content</div>
<div id="div2" class="draggableDiv">yet more content</div>
<div class="droppableDiv">drop it here</div>
$(document).ready(function() {
$('.draggableDiv').draggable({helper: 'clone'});
$('.droppableDiv').droppable({
accept: '.draggableRecipe',
drop: function(ev, ui) {
ui.draggable.clone().fadeOut("fast",
function() {
$(this).fadeIn("fast")
}).appendTo($(this).empty());
// function to set someVar = div[index];
}
});
});
I am not sure how best to accomplish this, so if anyone has any suggestions, I'd appreciate some guidance.
Thanks!