Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-12-2009, 01:20 PM   PM User | #1
metazai
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
metazai is an unknown quantity at this point
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?
metazai is offline   Reply With Quote
Old 11-12-2009, 04:34 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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...
__________________
Fumigator is offline   Reply With Quote
Old 11-13-2009, 08:49 PM   PM User | #3
metazai
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
metazai is an unknown quantity at this point
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?
metazai is offline   Reply With Quote
Old 11-13-2009, 10:59 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Old 11-14-2009, 01:32 AM   PM User | #5
metazai
New to the CF scene

 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
metazai is an unknown quantity at this point
No, I'm afraid that's still not working. Am I using the
Code:
$(this).parent().remove();
correctly?
metazai is offline   Reply With Quote
Old 11-14-2009, 05:44 AM   PM User | #6
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:52 PM.


Advertisement
Log in to turn off these ads.