Hello,

I'm experiencing some odd behavior with a sortable tree when I try to add an element using _javascript_ via rjs.  What's strange is that things work fine if I have moved any item on the list prior to adding a new element but produce odd results if I haven't.

My tree is a normal nested group of ul's and I have the call to Sortable.create in a partial so that I can refresh the list when I add elements.

The rjs for creating a new element includes the following two lines:
page.insert_html :bottom, "category_#{Category.root.id}", "<li>test<ul></ul></li>"
page.replace_html 'sortable', :partial => 'sortable_function'

I'm calling Sortable.create using the following code for initial testing:
<script> Sortable.create('category_<%=Category.root.id%>', {tree: true}); </script>

As noted, this works fine if I have already moved items around on the list.  But if I haven't, the new item is added as a list item under the final leaf node on the tree and only the new item acts as sortable.  I can't figure out why moving items around (even if I don't change the order) prior to adding a new one would cause such different results.

Any help would be greatly appreciated.

- Justin
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to