Probably a dumb question... sortable list - sending sort order to a database - SOLUTION COMPLETE
Thanks for the replies guys!
Got me headed in the right direction and I now have it working. Here's
my solution, in case i's useful / of interest to someone else:
on the actual page:
$('#categories').sortable({
update: function(){
sendOrder('calendar');
}
});
callback function:
function sendOrder(section) {
serialData = [];
var submitData = '';
list = $('#categories li');
for (var count = 0; count < (list.length-1); count++) {
var thisElementId = list[count].getAttribute('id');
submitData = submitData+count+'='+thisElementId+'&';
}
submitData = submitData+"section="+section;
$.ajax({
url: "_categoryAdmin/processCatOrder.php",
type: "get",
data: submitData,
});
};
I had a problem getting jQuery to serialize an array (it doesn't seem
to do it, so I simply built a data string. I have categories in
different sections and different tables, but with a central admin, so
it was easy to finish off teh string with the section information
preventing any extraneous '&' at the end or begining.
The php file just uses a foreach() to loop through each entry and
update each row in the table.
I hope this is of use, and thanks again to the guys who replied and
got me moving in the right direction.
Cheers
Keith