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

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