[Nottingham] AJAX'y lists

Penfold Q penfoldq at penfoldq.co.uk
Thu Nov 1 22:35:33 GMT 2007


Hi All

I've tried to google for this but I don't know what search terms to put 
in to get the right sort of results so I'm mainly looking for pointers 
on how to think about the problem than a made-to-measure solution.

A lot of AJAX'y websites have the ability to reorder items in a list by 
simply dragging them around the page. When you let go, the item is 
placed in that position and everything else repositions itself around 
this. I'm specifically thinking about how facebook lets you move 
sections around your profile to fit how you want it laid out.

So I want to build pages for my own use whereby simple lists can be 
manipulated in this sort of way. For example, a list of books to read or 
dvd's to watch where I can move items around the list to promote/demote 
them and the rest of the list reorders itself around this new placement.

It seems obvious that the structure for this is to have each element of 
the list as a record in a database of some sort and when an item is 
moved, it's newly calculated "position index" or whatever is written 
into it's record. A bit like old BASIC programming where lines are 
initially given numbers with a step of 10 and new lines can be inserted 
by giving them a number inbetween like 25 and then a function like 
'renumber' gives all lines a step of ten again handling the change to 
all the rest of the lines itself. But this seems like a lot of database 
updates to do atomically.

Am I thinking of this all wrong? How should I structure the database? 
Should I even use a database for the ordering?

Any thoughts?

-Penfold




More information about the Nottingham mailing list