Skip to content

Instantly share code, notes, and snippets.

@kiyotakagoto
Created November 22, 2011 09:07
Show Gist options
  • Select an option

  • Save kiyotakagoto/1385253 to your computer and use it in GitHub Desktop.

Select an option

Save kiyotakagoto/1385253 to your computer and use it in GitHub Desktop.
jQuery UI の droppable と drabbagle で要素をD&D移動
$('#container1').droppable({
accept : '.element',
drop : on_drop
});
$('#container1').children().each( function () {
$(this).draggable({
snap : true,
revert : true
});
});
$('#container2').droppable({
accept : '.element',
drop : on_drop
});
function on_drop (e, ui) {
var directory = $('#' + get_destination_id(e) );
var files = $('.ui-draggable-dragging');
files.appendTo(directory)
.css('top', '0px')
.css('left', '0px');
}
function get_destination_id ( event ) {
return event.target ? event.target.id
: event.srcElement.parentNode.id
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment