Tom Wilcoxen
2005-Aug-08 10:08 UTC
[Rails-spinoffs] Sortable or dragdrop to move items from one collection to another?
I need to present the user with a collection of players and one to many teams. The user can drag a player to a team or from one team to another. I started out using plain drag-drop, but was having trouble updating both the from list and the to list. E.g. if a player goes from team1 to team2 I need to update both of those divs. I can do the team2 div easy enough, but the player record still shows in the team1 div too. The Sortable :containments functionality seems to provide this pretty nicely. I changed to use that and now the visual drag/drop looks and works nicely (with the exception of the empty-list issue others have discussed). However, I don''t really care about the sort order and I don''t really want to update each player in the collection each time a player is moved. But with the Sortables I get the whole collection. I could probably do some trickery to tell which player changed (storing the serialized lists on the session or such), but it starts to seem that I''m using the wrong tool at that point and that it should be easier. So it seems to me that regular drag drop is really called for and maybe I''m missing how to update both the ''from'' and ''to'' divs. Does anybody have any advice for the best approach? Is there maybe something simple I''m missing? :) Thanks! Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20050808/346d399d/attachment.html