views:

31

answers:

0

Hi there... I have the following table using the MySQL adjacency list model:

id   | parent  | name      | order
-----------------------------------
1    | 0       | Kitches   | 1
4    | 0       | Chairs    | 2
5    | 0       | Sofas     | 3
43   | 4       | Blue      | 1
44   | 4       | Red       | 2

Implemented the Jquery nestedSortable and used the sortable STOP event, like this:

$('ol#navigation').nestedSortable({
 disableNesting: 'no-nest',
 forcePlaceholderSize: true,
 handle: 'div.liContent',
 items: 'li',
 opacity: .6,
 placeholder: 'placeholder',
 tabSize: 25,
 tolerance: 'pointer',
 toleranceElement: '> div.liContent',

 stop: function(event, ui) {
  var serialized = $('ol#navigation').nestedSortable('serialize');
  var movedItem = ui.item.attr('id');
  editOrdemCat(serialized, movedItem);

  //alert(movedItem);
 }

});

So as soon as drag stops i call a global JQuery function called editOrdemCat passing two variables: serialized wich is the default sortable serialization and movedItem wich contains the LI element ID that we actually moved (in case i might need it, who knows?).

I will not include my UL HTML as you already know the drill. Thing is, i might have to play a litle bit with the LI id's in order to achieve what i ask.

I've looked around and cocluded that the best way would be using a nested set model. Too late for that, did not make my homework before project started. Too many PHP functions relying on what i already have.

So goal is to update my messy table with an ajax post on my editOrdemCat jquery function. Any ideas about the PHP code/logic on how to achieve this? Taking into place, the parent and order columns/criteria ?

Thanks in advance...