> > and then I add dynamically further <li> elements and create a Sortable > > but the onUpdate only fires for <li> items that have not been created > > via Javascript. > > > > I wonder if that's the same issue I'm having. My elements were created > via javascript and I cannot get the onUpdate to fire at all. At least > that knowledge might help me figure it out. I'll be digging into it > more today. >
So, my problem was that because I was using innerHTML += 'html code here'; for some reason the 'id' on the childNodes were not being set correctly. If I manually set the id in javascript, then the onUpdate was firing. That apparently is your issue as well. The Sortable determines that something has changed by calling Sortable.serialize() before and after the drag and comparing the results. Sortable.serialize() determines it's value based on the id's of the elements in the Sortable. They need to be something akin to 'section_24' (i.e. a word, followed by 1 underscore, then a distinct value, such as a numeric id). This code should fix your problems (only diff is adding the id's in both the HTML and Javascript): <ul id="secondlist"> <li id="item_1">bla bla</li> <li id="item_2"> bla bla </li> </ul> <script type="text/javascript"> // <![CDATA[ for(i=0;i<20;i++) { var node = Builder.node('li', 'element'+i); node.id = 'item_' + (node.childNodes.length + 1); $('secondlist').appendChild(node); } Sortable.create("secondlist", {onUpdate:listUpdate, tag:'li', containment:["secondlist"]} ); function listUpdate(){ alert("update"); } // ]]> </script> Greg _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs