Forum: Ruby on Rails sortable_element not recognizing newly added <li> elements

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.
Jim J. (Guest)
on 2006-01-05 12:22
(Received via mailing list)
I have a user defined list of items.  Using the sortable_element
function, I can manipulate the ordering of this list fine by dragging
each component around.

When I dynamically add another <li> item to this list, the newly added
item is _not_ "draggable" like its other siblings.

Using the sortable_element function, how do I make it aware of newly
added list items?  Here is my current sortable_element definition.

<%= sortable_element dow + 'orderList',
        :complete => visual_effect(:highlight, "status", :duration =>
0.5 ),
        :url => { :action => 'updateOrder', :dow => dow } %>

TIA.


Jim
Jim J. (Guest)
on 2006-01-05 22:01
Jim J. wrote:
> I have a user defined list of items.  Using the sortable_element
> function, I can manipulate the ordering of this list fine by dragging
> each component around.
>
> When I dynamically add another <li> item to this list, the newly added
> item is _not_ "draggable" like its other siblings.
>
> Using the sortable_element function, how do I make it aware of newly
> added list items?  Here is my current sortable_element definition.
>
> <%= sortable_element dow + 'orderList',
>         :complete => visual_effect(:highlight, "status", :duration =>
> 0.5 ),
>         :url => { :action => 'updateOrder', :dow => dow } %>
>
> TIA.
>
>
> Jim

Found a solution to my problem.  Looks like I need to recreate the
sortable_element each time a new <li> item is added.

Here's a description of the problem.
http://dev.rousette.org.uk/ticket/136

And here's a source exemplifying the solution.
http://dev.rousette.org.uk/file/trunk/tracks/app/v...

You want to call the Sortable.create method within the :OnComplete
callback.

Jim
This topic is locked and can not be replied to.