The code below is form the Seaside book at: http://book.seaside.st/book/web-20/jquery/enhanced-todo-application/drag-and-drop
html jQuery new sortable
onStop:
(html jQuery ajax
callback: [ :items | modelRole getModelRolePlayer setItemList: items ]
passengers: (html jQuery this find: 'li'));
axis: 'y'
My instance variable _itemList is initially OrderedCollection. As soon as I move the rows around in the page then entire list is sent back in it's new order. However, this time setItemList: receives an Array.
Does this make any sense? Am I missing something?
So the problem is that #callback:passenger:
uses #subStrings:
to get the element ids from the AJAX callback and then does a #collect:
on that collection to determine the Smalltalk objects. Since #subStrings:
returns an array, the #collect:
will also return an array.
The solution: send #asOrderedCollection
to the array before storing it:
(html jQuery ajax
callback: [ :items | modelRole getModelRolePlayer setItemList: items asOrderedCollection ]
passengers: (html jQuery this find: 'li'));