Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding and removing between connected lists

    Greetings! I'm somewhat of a jquery noob, so please be kind . . .

    I have a page where a user can drag options into a box and order them as they see fit. It's NDA for a client, unfortunately, but it's more or less built exactly on the brilliantly simple code stickman posted at: http://the-stickman.com/files/jquery...-sortable.html

    Which is great, but what if I want the user to be able to REMOVE an item from the box, just drag it out into the ether and have it disappear? It can still be dragged in from the initial lists, of course, but to remove it from the box with the same "dragging" interface seems natural -- only I can't see how to do it. Any ideas?

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I haven't done much with drag/drop (just a little experimentation) but it seems to me you can assign the outer div as a droppable object with a callback function that removes the object being dropped on it. Worth a shot...

  • #3
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wrapped one of the original "drag from" lists in a droppable div id, and added this to the bottom.


    Code:
    jQuery('#droppable').droppable({
          drop: function() {
    		$(this).parent().remove();
    		 return false;
     }
    As you may have guessed, it doesn't work. It removes the #droppable div.

    I've tried some variations, but they just break it further. Suggestions?

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    What if you created a little div with a graphic of a trash can on it and made that droppable? Then you can just remove anything that's dropped on it.

  • #5
    New to the CF scene
    Join Date
    Jun 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, I'm afraid that's still not working. Am I using the
    Code:
    $(this).parent().remove();
    correctly?

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    I dunno, is it selecting the correct element? If in doubt, you can always stick an id on the element and select it directly using the id.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •