<script type="text/javascript">
function resetSortable() {
$("#navcatlist").sortable(
{
opacity: 0.7,
placeholder: 'ui-state-highlight',
revert: false,
dropOnEmpty: true,
cancel: 'img',
scroll: true,
items: 'li',
helper: 'original',
opacity: 0.85,
zIndex: 55,
containment: '#containment',
tolerance: 'intersect',
cursor: 'move',
connectWith: '#maincatlist',
delay: 20,
receive: function (event, ui) {
alert('new nav category');
/* $item = ui.item;
$(ui.helper).children('img').toggleClass('hidden unhidden');
//Destroy the draggable and release all event handlers
//$("#maincatlist").draggable("destroy");
setTimeout($item.remove(),1000);
// $("#maincatlist > " + id).remove();
*/
}
});
}
$(document).ready(function () {
var $maincatlist = $("#maincatlist"), $navcatlist = $("#navcatlist");
$('li', $maincatlist).draggable(
{
scroll: true,
helper: 'clone',
opacity: 0.80,
revert: 'invalid',
//appendTo: '#container',
cursor: 'move',
connectToSortable: '#navcatlist',
delay: 20,
stop: function (event, ui) {
alert('fired drag stop');
}
});
$maincatlist.droppable(
{
activeClass: 'ui-state-highlight',
hoverClass: 'topDrop',
accept: '#navcatlist > li',
drop: function (event, ui) {
alert('removed nav category');
//Grab the ID of the ui.draggable object
var id = ui.draggable.attr("id");
//Destroy the sortable and release all event handlers
$("#navcatlist").sortable("destroy");
//Append the JQuery object using the ID attained above to the droppableDiv
$("#" + id).appendTo($(this));
//resetSortable();
$(this).children('img').toggleClass('hidden unhidden');
},
connectWithSortable: '#navcatlist'
});
resetSortable();
});