Created
June 17, 2014 19:22
-
-
Save zackn9ne/2c593cc55968722941fe to your computer and use it in GitHub Desktop.
app.js for drops
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
| $(function(){ //same as document ready | |
| var info = []; //get ready the array called info | |
| //who is draggable, cards | |
| $( ".ui-draggable" ).draggable({ | |
| connectToSortable: "#card-pile", | |
| stack: '#content', | |
| revert: "invalid" | |
| }); | |
| //do something for each draggable thing in case | |
| $( '.ui-draggable' ).each(function() { | |
| }); | |
| //who can take a drop, slots | |
| $('li.slot').droppable( { | |
| accept:'.ui-draggable', | |
| hoverClass: 'hovered', | |
| drop: | |
| function( event, ui ) { | |
| ui.draggable.position({ | |
| of: $(this), | |
| my: 'left top', | |
| at: 'left top' | |
| }); | |
| $(this).droppable ( "disable" ); | |
| // $(ui.draggable).doSomething(); | |
| var eP = { | |
| choice: $(this).attr("id"), | |
| target: $(this).parent().attr("id") | |
| }; | |
| info.push(eP); | |
| console.log (info); | |
| } | |
| }); | |
| //sortable area | |
| $( "#sortable" ).sortable({ | |
| revert: true | |
| }); | |
| //messy area | |
| $.each(info, function(i, pos) { | |
| if ($(ui.draggable).attr("id") == pos.choice) { | |
| pos.target = $(cT).attr("id"); | |
| } | |
| }); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment