# Sortable List with RJS

**URL:** <https://www.ruby-forum.com/t/sortable-list-with-rjs/137939>\
**Category:** Rails\
**Created:** [May 18, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/sortable-list-with-rjs/137939 "2008-05-18T17:47:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [May 18, 2008, 5:47pm UTC](https://www.ruby-forum.com/t/sortable-list-with-rjs/137939/1 "2008-05-18T17:47:05Z")

</div>

Hi,

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?

Thanks,

DAZ

---

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [May 19, 2008, 5:40pm UTC](https://www.ruby-forum.com/t/sortable-list-with-rjs/137939/2 "2008-05-19T17:40:13Z")

</div>

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

, then each - should probably have an id  
like ‘person\_n’. Have you got that?

---

<div class="post-metadata">

**Author:** ![daz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/87869e/32.png) [@daz](https://www.ruby-forum.com/u/daz)\
**Post date:** [May 19, 2008, 11:24pm UTC](https://www.ruby-forum.com/t/sortable-list-with-rjs/137939/3 "2008-05-19T23:24:33Z")

</div>

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,

DAZ
