Sortable_element not recognizing newly added <li> elements


#1

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

  • 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


  • #2

    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

  • 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

  • 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/views/context/list.rhtml

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

    Jim