Does rails have a way to easily implement droppables for dynamically
changing lists. I’d like to be able to take my database of employees,
and my database of projects for that day and assign employees to
projects by dropping them onto the project. My problem is, the
projects are different every day, so I need to figure out how to create
my groups dynamically.
Does rails have a way to easily implement droppables for dynamically
changing lists. I’d like to be able to take my database of employees,
and my database of projects for that day and assign employees to
projects by dropping them onto the project. My problem is, the
projects are different every day, so I need to figure out how to create
my groups dynamically.
Thanks
What I have done in these cases is to create a helper function that
inserts the appropriate javascript block and call that function once
for each droppable. Not the use of the :with parameter in the
link_to_remote call. This will be executed as javascript in the
context of the onDrop callback, this is how I get the id of the
dropped employee. Code is untested, so there are likely some bugs in
there, but the general idea works.
Sorry for the delay when I run the new piece of code I get a syntax
error. The little arrow shows the error on the close parenthesis
behind element.employee_id. If I only remove the # at {remote_function
I get “can’t find string “HTML” anywhere before EOF”
I figured it out. There were a few bugs in your code, but I fixed
them. Also the javascript for add employee is completely incorrect,
simply using the rails built in method works great.
<%= draggable_element “employee_#{employee.id}”, :revert => true %>