# Sortable\_element trouble

**URL:** <https://www.ruby-forum.com/t/sortable-element-trouble/153514>\
**Category:** Rails\
**Created:** [November 18, 2008, 8:52am UTC](https://www.ruby-forum.com/t/sortable-element-trouble/153514 "2008-11-18T08:52:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [November 18, 2008, 8:52am UTC](https://www.ruby-forum.com/t/sortable-element-trouble/153514/1 "2008-11-18T08:52:00Z")

</div>

I need some reordering functionality so I tried the sortable\_element  
helper. It is giving me trouble though. I have a show view that looks  
like this (HAML):

%ul#items  
= render :partial =\> @menu.items  
= sortable\_element :items, :url =\> { :action =\> ‘inspect\_params’ },  
:complete =\> “alert(request.responseText);”

I’m doing two things here: Rendering a partial with a lot of menu items  
(that should be able to be reordered) and output a piece of Javascript  
that creates a new Sortable. The output looks like this:

- Home
- About
- Contact

The inspect\_params action in the MenusController looks like this:

render :text =\> params.inspect

And that’s about it. This is every Javascript developer’s nightmare:  
Nothing happens at all. And the nightmare has become true. No alert box,  
not even a request. If you open Firebug and drag some list items around,  
nothing happens in the console.

And do you know what the real funny thing is? If you make a link to the  
same action on the same page, it works fine!

= link\_to\_remote “Link”, :url =\> {:action =\> ‘inspect\_params’}

The request gets sent and returns something like:  
{“authenticity\_token”=\>"…", “action”=\>“inspect\_params”, “controller”  
=\> “menus”} I’ve been wondering if it has anything to do with the way I  
positioned the Javascript: in the bottom of . Is that good?

Can anyone help me out here? This problem has twisted my brain for two  
days…

---

<div class="post-metadata">

**Author:** ![davidtl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/35a633/32.png) [@davidtl](https://www.ruby-forum.com/u/davidtl)\
**Post date:** [November 18, 2008, 9:39am UTC](https://www.ruby-forum.com/t/sortable-element-trouble/153514/2 "2008-11-18T09:39:15Z")

</div>

David T. wrote:

> Can anyone help me out here? This problem has twisted my brain for two  
> days…

OK, after a bit of research I found a solution:

[http://dev.rubyonrails.org/ticket/6489](http://dev.rubyonrails.org/ticket/6489)

Ghosting (for some reason) needs to be enabled to trigger a request…
