I want to drag elements with humor.
Now I have a "repository" with several elements.
On another site, I have x mailboxes. each box can contain only 1 item.
I am currently using the droppable function to set another class in a field, so that you can add only 1 field that works:
$( ".droppable" ).droppable({ accept: ".draggable", activeClass: "draghover", drop: function( event, ui ) { if($( this ).hasClass("droppable")) { $( this ).removeClass("droppable").addClass( "droppable-"); } } });
Now I need to return the class when I move the item to the repository or to another. I tried this with the draggable.start function, but I cannot get the correct parent ()
$( ".draggable" ).draggable({ revert: "invalid", snap: ".droppable", snapMode: "inner", start: function( event, ui ) { alert($( this ).parent().attr("Class")); } });
this will return the initial position all the time before the first drag. Not the last position.
Storage is as follows:
<td valign="top" class="warenlager" bgcolor="grey" width="200"> <div class="draggable" class="bild ui-widget-content" id="s73-1">S</div> <div class="draggable" class="bild ui-widget-content" id="s74-1">S</div> </td>
The box looks like this:
<td><div class="droppable" id="element 2"></div></td>
Hello
source share