# Issue with Sortables and Rails. Is it Javascript/rails problem?

**URL:** <https://www.ruby-forum.com/t/issue-with-sortables-and-rails-is-it-javascript-rails-problem/185946>\
**Category:** Rails\
**Created:** [March 29, 2010, 4:09pm UTC](https://www.ruby-forum.com/t/issue-with-sortables-and-rails-is-it-javascript-rails-problem/185946 "2010-03-29T16:09:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![droopy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/47e85d/32.png) [@droopy](https://www.ruby-forum.com/u/droopy)\
**Post date:** [March 29, 2010, 4:09pm UTC](https://www.ruby-forum.com/t/issue-with-sortables-and-rails-is-it-javascript-rails-problem/185946/1 "2010-03-29T16:09:53Z")

</div>

Hi there,

I have an issue with Sortables that I can’t figure out. I’m not sure if  
this issue is related to Sortables or if it is a more generic  
Javascript/Rails interaction issue

Let’s say I have a sortable with a list of items, but the top 3 elements  
have special meaning.  
What I’d like to accomplish is to be able to identify if the element  
that is moved in my sortable belongs to the top 3. And if this is the  
case, I have some action to apply to it.

I’ve seen that there is an onChange option in the sortable\_element which  
allows me to identify the element, but this is JavaScript code at this  
point.

\<%= sortable\_element ‘messages’,  
:url =\> {:action =\> ‘sort\_messages’},  
:onChange =\> “function(element){moved\_message = element.id}”  
%\>

Does anyone knows how to access this javascript variable in my  
sort\_message action?  
Apologies if I’m not clear enough,

Thanks in advance,

Christophe
