Drag and Drop to multiple, dynamic lists

Hello,

I am attempting to create an admin tool so that admins can drag and drop "users" to add them to a "group". Once I have dropped the users into the group element, I want to update my group_users table which is HABTM.

So far, I have properly created a draggable element for each user:

<%= draggable_element "#{user.id}", :revert => true %>

I am also using the drop_receiving_element for each group (properly accessed "add" when item is dropped) <%= drop_receiving_element "group#{group.id}", :url => { :action => "add"}, :accept => "users", :loading => "Element.show('indicator')", :complete => "Element.hide('indicator')" %>

What I need to also pass is the group.id so that I can update the group_users table upon drop. In all the documentation I've read about scriptaculous drag-and-drop & drag-and-drop sortable-lists, nothing is explained about the options you can pass to the drop_receiving_element tag.

Has anyone implemented this with dynamic lists?

Thanks! -Dina

I have finally found a solution:

You can set additional params in the url so my drop_receiving element tag is now:

<%= drop_receiving_element "group#{group.id}", :url => { :action => "add", :group_id => "#{group.id}" }, :accept => "users", :loading => "Element.show('indicator')", :complete => "Element.hide('indicator')" %>

The user id from the draggable element is automatically set for params[:id]. To update params[:id] you would use the :with option in the drop_receiving_element...not what I wanted since I need both group id and user id for my join table.

Hope this helps anyone working on anything similar. -Dina