Adding AJAX edit-in-place to a sortable list

S

strawberry

Hi all,

I'm trying to add prototype/scriptaculous 'edit-in-place' functionality
to a sortable list.

The sortable bit works really well: A list of <li> elements is
populated by data gathered from a mysql db.
Dragging the elements of the list around, or clicking a little
trashcan, causes UPDATE statements to be sent back to the db. Awesome.
It's just the edit-in-place but that falls down. I've read a couple of
online tutorials but still I'm stuck.
I'm reluctant to paste too much code, for fear of boring readers to
death so I'll just try to show (what I think is) the salient bit...
If you need to see more, the css, the functions or whatever just let me
know.

Here's the php'd html for the <li> elements:

<li id="'
.. htmlentities($row['id'])
.. '"><table width="100%" bgcolor="#'
.. htmlentities($hex)
.. '"><tr align="left" valign="top"><td width="70" align="left">'
.. htmlentities($row['part_code'])
.. '</td><td align="left"><a href="#">' //I GUESS THIS LINE NEEDS
UPDATING TOO!!!
.. htmlentities($row['item'])
.. '</a></td><td>&nbsp;</td><td align="right"><a href="#"
title="Delete!" onclick="process('
.. htmlentities($row['id'])
..',' . htmlentities($delItem)
.. ')"><img src="trash.gif"></a></td></tr></table></li>'
.."\n";

And here's the kind of thing I think I'm supposed to tag on to the
end of it in order to allow for the edit-in-place functionality:

<script type="text/javascript"> new Ajax.InPlaceEditor("item_'
. htmlentities($row['id'])
. '","some_function.php",{callback: function(form, value) { return
"name=" + escape(value)+"&id='
. htmlentities($row['id'])
. '}});</script>'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top