# Drag and drop problem

**URL:** <https://www.ruby-forum.com/t/drag-and-drop-problem/51905>\
**Category:** Rails\
**Created:** [January 9, 2006, 3:06am UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905 "2006-01-09T03:06:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 9, 2006, 3:06am UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/1 "2006-01-09T03:06:01Z")

</div>

I am working on a resource planning problem. I like to use a nice drag  
and drop interface for that. E.g. have a box of persons and a box of  
projects, now I would like to assign a persom to project by dragging it  
from the available resources box to a recieving project box.

I have studied the amazing drag and drop shopping card code listed here  
[http://demo.script.aculo.us/shop](http://demo.script.aculo.us/shop)

What I need to change is that the resources (products in the cart  
example) should be deleted from the list of available persons after an  
assignment is done (I can do a :revert =\> false, but that is only part  
of the job.).

Even more challaging is to found a way of reassigning a resource: I  
would like to get a person back from a project into the pool of  
available persons again.

I tried lots of things but I cannot make the drop action (form the  
shopping card div bacl into the products div) update the products div.  
The cart div is the only one updated. I wonder if it is the nesting of  
the divs that can make it work ? A drop on the waste bin does update the  
shopping cart, also, so there should be simple trick to get the products  
box to be updated also (maybe reflecting new stock levels ??)

Any hints or pointers are more then welcome,

Thanks,

Matthijs

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 9, 2006, 5:29am UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/2 "2006-01-09T05:29:17Z")

</div>

On 1/9/06, Matthijs [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> example) should be deleted from the list of available persons after an  
> the divs that can make it work ? A drop on the waste bin does update the  
> shopping cart, also, so there should be simple trick to get the products  
> box to be updated also (maybe reflecting new stock levels ??)
> 
> Any hints or pointers are more then welcome,

Basically you have 2 boxes and you want to be able to drag-drop from one  
box  
to another.The first one being available resources and the second one  
being  
the assigned resources.Is that right?

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 9, 2006, 10:58am UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/3 "2006-01-09T10:58:19Z")

</div>

Vivek K. wrote:

> Basically you have 2 boxes and you want to be able to drag-drop from one  
> box  
> to another.The first one being available resources and the second one  
> being  
> the assigned resources.Is that right?

Thats is correct, my main problem is to figure out to update BOTH boxes  
on a drop event.

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 9, 2006, 3:17pm UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/4 "2006-01-09T15:17:47Z")

</div>

Here you go…I couldnt figure out a simpler way other than to tinker  
with  
the id of the elements you want to drag and drop.  
You need to modify the id’s of elements depending on which box they are  
in.  
I have 2 boxes a and b.the available resources and the used resources in  
your case. I modify the id’s of the elements as a1,a2 and b1,b2  
according to  
where they are at the moment.

Hope this helps…I havent tested on IE.

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 10, 2006, 4:45am UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/5 "2006-01-10T04:45:30Z")

</div>

Hi Matthijs,  
What code are you talking of ? I sent the entire HTML code .Hope you  
got  
that.  
Vivek

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 9, 2006, 4:33pm UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/6 "2006-01-09T16:33:00Z")

</div>

Vivek K. wrote:

> Hope this helps…I havent tested on IE.

OK thanks I get the idea, i am now tryling implement it, could you post  
the code you used for testing here, I guess that would be helpfull, also  
for others reading this list.

If I manage to get it working I will also post the code for the  
sollutions here.

regards, and thanks for the help so far …

Matthijs

---

<div class="post-metadata">

**Author:** ![Matthijs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8797f3/32.png) [@Matthijs](https://www.ruby-forum.com/u/Matthijs)\
**Post date:** [January 10, 2006, 11:01pm UTC](https://www.ruby-forum.com/t/drag-and-drop-problem/51905/7 "2006-01-10T23:01:55Z")

</div>

oops…I think the attachement didnt come through eariler…  
I am pasting the HTML

OneTwo

Click here  
to  
know who has what
