Hi Gregory,
thanks for figuring it out!
Another thing is, Sortable.serialize() returns following string:
Recieved Ajax Request:
Ajax=true&secondlist%5b%5d=1&secondlist%5b%5d=2&secondlist%5b%5d=3&secondlist%5b%5d=5&secondlist%5b%5d=4&_=
Seems strange to me (some sort of Base64 encoding?), do I need to
specify any specific encoding on the Ajax.request ?
Thanks,
Max
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
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs