Jquery drag /drop and clone

Posted by Sajeev on Stack Overflow See other posts from Stack Overflow or by Sajeev
Published on 2010-01-20T11:17:17Z Indexed on 2010/05/16 22:30 UTC
Read the original article Hit count: 257

Filed under:
|

Hi I need to achive this ..

I have a set of droppable items ( basically I am droping designs on a apparel ) and I am dropping a clone..

If I don't like the dropped object (designs) - I want to delete that by doing something like hidden .

But I am unable to do that.

Please help me..


here is the code

    var clone;
    $(document).ready(function(){
        $(".items").draggable({helper: 'clone',cursor: 'hand'});


     $(".droparea").droppable({
                    accept: ".items",
                    hoverClass: 'dropareahover',
                    tolerance: 'pointer',
                    drop: function(ev, ui)
                    {

              var dropElemId = ui.draggable.attr("id");

              var dropElem = ui.draggable.html();

                      clone = $(dropElem).clone(); // clone it and hold onto the jquery object
                      clone.id="newId";
                      clone.css("position", "absolute");
          clone.css("top", ui.absolutePosition.top);
                      clone.css("left", ui.absolutePosition.left);
              clone.draggable({ containment: 'parent' ,cursor: 'crosshair'});

                      $(this).append(clone);
                      alert("done dragging ");

                      /lets assume I have a delete button when I click that clone should dissapear so that I can drop another design - but the following code has no effect 
                      //and the item is still visible , how to make it dissapear ?
                      $('#newId').css("visibility","hidden");



               }
        });



    });

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about drag-and-drop