Created
November 22, 2011 09:07
-
-
Save kiyotakagoto/1385253 to your computer and use it in GitHub Desktop.
jQuery UI の droppable と drabbagle で要素をD&D移動
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#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