How to drop a sortable block?

Posted by Pentium10 on Stack Overflow See other posts from Stack Overflow or by Pentium10
Published on 2010-03-15T17:35:50Z Indexed on 2010/03/15 17:39 UTC
Read the original article Hit count: 183

Filed under:

I have a list which is reordered using sortable.

I defined a trash can div, and I want to achieve that when the blocks are dropped on this div to get deleted. So far I can't seam to fine the way to fire the drop event, when I release the item gets back to his previous position.

I have this code:

$(document).ready(function() {
    var order = null;
    $("#order-list").load(location.href+" #order-list>*","");   
    $("#order-list").sortable({
      handle : '.handle',
      update : function (e, ui) {
             order = $(this).sortable('serialize');
         $("#info").load("process-sortable.php?"+order);
    }
    });

});

and

$("#trashcan").droppable({
        drop: function(event, ui) {
                draggedid = ui.draggable.attr('id');
                alert(draggedid); // doesn't fire
                $.get("process-add-subcat.php", 
                             { 
                                "action"   : "delete_subcategory", 
                                "draggedid": draggedid
                             },
                       function(data){

                       }); 
            }
        });

© Stack Overflow or respective owner

Related posts about jQuery