Skip to content

Instantly share code, notes, and snippets.

@malero
Created September 14, 2010 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save malero/579596 to your computer and use it in GitHub Desktop.
Save malero/579596 to your computer and use it in GitHub Desktop.
#sortable-delete {
height: 18px;
overflow: hidden;
background: url('/resources/img/bin.png') 0 50% no-repeat;
}
#sortable-delete li {
height: 0;
width: 0;
overflow: hidden;
}
ul.sortable {
padding-bottom: 5px;
}
ul.sortable li {
cursor: pointer;
}
<ul id="sortable-delete" class="sortable"></ul>
<ul class="sortable">
<li>Item 1</li>
<li>Item 2</li>
</ul>
<ul class="sortable">
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
</ul>
jQuery(function() {
// Make all ul.sortable lists into sortable lists
jQuery('ul.sortable').sortable({
tolerance: 'pointer',
cursor: 'pointer',
dropOnEmpty: true,
connectWith: 'ul.sortable',
update: function(event, ui) {
if(this.id == 'sortable-delete') {
// Remove the element dropped on #sortable-delete
jQuery('#'+ui.item.attr('id')).remove();
} else {
// Update code for the actual sortable lists
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment