Forum: Ruby on Rails sortable_element does not initiate AJAX calls

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-05-31 01:38
Having an odd problem with sortable_element.  The :url option doesn;t
seem to actually work.  No AJAX calls are being generated.  I can tell
because Firebug extension does not show any AJAX requests, and the
development.log file does not do anything when droppping the items in
new positions.

Here is the code I am using for sortable generation:

  <%= sortable_element 'images',
        :url => {
          :action => 'reorder_images',
          :id => @product
        },
        :overlap => :horizontal,
        :constraint => false,
        :tag => :div
  %>

Which generates the following javascript:

  <script type="text/javascript">
  //<![CDATA[
  Sortable.create("images", {constraint:false, onUpdate:function(){new
Ajax.Request('/admin/products/reorder_images/1', {asynchronous:true,
evalScripts:true, parameters:Sortable.serialize("images")})},
overlap:'horizontal', tag:'div'})
  //]]>
  </script>

the onUpdate portion of the sortable looks correct, but no AJAX
requested is created.  The sortable_elements pieces are draggable and
dropppable, and I can reorder any way I please, but with no way to save
it's kind of moot.

Has anyone else managed to get this working?  Am I missing something
stupid?  Is this a bug in prototype/scriptaculous?
D0cd6b10e01bacb976b3b815a9c660bc?d=identicon&s=25 Alex Wayne (Guest)
on 2006-05-31 02:15
Alex Wayne wrote:
> Having an odd problem with sortable_element.  The :url option doesn;t
> seem to actually work.  No AJAX calls are being generated.  I can tell
> because Firebug extension does not show any AJAX requests, and the
> development.log file does not do anything when droppping the items in
> new positions.

found the solution here: http://www.ruby-forum.com/topic/66894

Apparently, the sortable elements must have an id in the proper format
or Sortable.serialize just silently fails aborting the AJAX call.  The
proper id format is:

  <div id="sortablecontainer">
    <div id="item_1">a</div>
    <div id="item_2">b</div>
  <div>

There should really be a javascript error thrown if Sortable.serailze
fails.
This topic is locked and can not be replied to.