(Ruby, Rails, Javascript) Drag and Drop without bugging the server…?
-
14-09-2019 - |
Question
Is there an equivalent of "link_to_function" (instead of ":action") when using "draggable_element"? Basically I need to drag and drop some items and have it reflected locally without contacting the server.
My current setup is that I have two DIVs with various list items. I have one full of items with domids "points[selected][name]" and another div with domids "points[available][name]". I need to drag and drop between them without consulting the server. Only on save do I wish to bother the server.
I've watched all the RailsCasts on similar items, but it doesn't seem to cover having a non-standard action (i.e. Helper Function) triggered from a "draggable_element" method.
Thanks in advance!
Solution
From the top of my head I would say: don't use the helper that rails provides. Write your own JS to do the UI manipulation since you need a custom action.
Okay, not that helpfull, but I think it's the best way.
OTHER TIPS
Off the top of my head, can't you just omit the :action from the sortable_element call and include the new sort order when you submit your form?