Sortable List with RJS


I want to use rjs to make a sortable list.

If I put this code in the index.html.erb view, it works: <%= sortable_element :people_list, :url => {:action => "sort" }, :tree => true %>

I thought that I should be able to put this code into a file called index.js.rjs: page.sortable 'people_list', :url => { :action => 'sort' }, :tree => true

This doesn't work, however. Is there something else I need to do?



Did you notice this warning from the Rails API: Important: For this to work, the sortable elements must have id attributes in the form "string_identifier". For example, "item_1". Only the identifier part of the id attribute will be serialized.

If 'people_list' is a <ul>, then each <li> should probably have an id like 'person_n'. Have you got that?

Yes, that bit is fine because the list works fine if the helper is in erb page. The problem seems to be trying to get the rjs page to work.

thanks for the suggestion,