[Seaside] How to Save a sorted list in Scriptaculous
Rajeev Lochan
lochan94 at gmail.com
Tue Aug 28 20:30:05 UTC 2007
Hi,
How does one save a sorted list back in the image ?
The details are as below.
ListView>> renderContentOn: html
html form: [
html render: self model title.
html div class: 'items';
script: (html sortable tag: 'div';
onUpdate: (html request
triggerSortable: 'items'
callback: [:col | self model items: col]));
with: [
self model items do: [:eachItem| self
renderItemOn:eachItem].
html submitButton callback: [self answer: self model]]]
ListView>> renderItemOn: anItem
html
table: [html
tableRow: [html tableData id: 'checkBoxItem';
with: [html checkbox value: anItem done;
callback: [:value | anItem done: value]].
html tableData id: 'myListEditItems';
passenger: anItem;
with: [
html render: anItem title]]]
The page is rendered and the items can be sorted. The sorting is only done
on the client end. If I submit the button, the new order of the items isn't
updated. Am I missing anything ?
a) I tried to introduce a self halt in
html sortable tag: 'div';
onUpdate: (html request
triggerSortable: 'items'
callback: [:col | self halt.self model items: col]));
It didn't halt for debugging.
b) I tried to introduce a temp variable which stores items, as follows,
ListView>> renderContentOn: html
| tempList |
tempList := List new.
tempList items: self model items.
html form: [
html render: self model title.
html div class: 'items';
script: (html sortable tag: 'div';
onUpdate: (html request
triggerSortable: 'items'
callback: [:col | tempList items: col]));
with: [
tempList items do: [:eachItem| self
renderItemOn:eachItem].
html submitButton callback: [self model items: tempList
items.self answer: self model]]]
I knew this wouldn't work either as I had failed earlier to update items
(which is an OrderCollection) by duplicating it and reassigning after
changes.
By googling around, I found a solution that has been implemented in PHP.
http://www.zenperfect.com/2007/07/26/sortable-lists-in-php-walkthrough/
I am not able to comprehend it properly.
In a nutshell, I have a list saved in my squeak image, I retrieve the list
for sorting. After sorting it, it should be saved in the submitted order.
Hoping to find some help,
Rajeev
PS: I am using Damien's 2.8 image
--
Rajeev Lochan
Co-founder, AR-CAD.com
http://www.ar-cad.com
+91 9243468076 (Bangalore)
080 65355873
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20070829/c74d79ad/attachment.htm
More information about the seaside
mailing list