Skip to content

Instantly share code, notes, and snippets.

@zackn9ne
Created June 17, 2014 19:22
Show Gist options
  • Select an option

  • Save zackn9ne/2c593cc55968722941fe to your computer and use it in GitHub Desktop.

Select an option

Save zackn9ne/2c593cc55968722941fe to your computer and use it in GitHub Desktop.
app.js for drops
$(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