Drag and drop sorting recipe


#1

The new pragmatic Rails Cookbook has a drag and drop sorting recipe.
Does
anyone know if this works with 1.0?

I’ve followed the recipe (i think), and I can drag but when I drop
everything goes back the way it was. It seems that the sort logic
doesn’t
get invoked.

I put this code in my view:

<%= sortable_element 'task-list' ,
    :url => { :action => "sort", :id => @user },
    :complete => visual_effect(:highlight, 'task-list' )
%>

which leads to this in the HTML:

//

but the sort method doesn’t get invoked on the drop. Any idea why?

thanks.


#2

On 3/23/06, Larry W. removed_email_address@domain.invalid wrote:

The new pragmatic Rails Cookbook has a drag and drop sorting recipe. Does
anyone know if this works with 1.0?

I’ve followed the recipe (i think), and I can drag but when I drop
everything goes back the way it was. It seems that the sort logic doesn’t
get invoked.

Larry, this indeed does work with 1.0. Eliminate the easy stuff first–
check that you have acts_as_list in your model, a position field in your
table, and, of course, javascript_include_tag :defaults somewhere in
your
view.

HTH,
Dean


#3

I have all those things setup. This is my model:

class TaskItem < ActiveRecord::Base
belongs_to :task
belongs_to :person
acts_as_list :scope => :person
end

This is the table:

CREATE TABLE task_item
( person_id int4 NOT NULL,
“position” int4 NOT NULL,
task_id int4 NOT NULL)

and the defaults tag is there. It causes three javascript files to be
loaded:

Any ideas on what to try next?


#4

Ok - it was working. I had been grabbing the list items by the list
item
symbol, and it worked for dragging but not dropping. As long as I grab
the
item by its name, the drop works - strange.

Thanks for your help.