johnny/jquery-sortable

Help wanted: Saving re-ordered structure

Opened this issue · 3 comments

Hi,

I have jquery-sortable working fine in my site page now, however, and sorry if this is a bit of a silly question, but how do I go about saving / getting access to the new structure once the user has done their dragging and dropping?

I am using it for the re-ordering of menu items, and the initial structure on page load is from a parent/child database table.

What I need to do is, on the press of a Save Changes button, update the database table with the changes, or re-create the table contents if needs be from the new UL / LI structure.

I have added to the LI's custom attributes with the parent/child ID's.

How would I do this please?

Thanks in advance.

Just as an addition to the above, I have now tried adding the serialization demo code in and it is showing in the PRE tag I have added changes as a JSON list when I move item about, but unless I have missed something / done something silly, the parent ID's are staying the same in the data-id attribute?

Are the move from one parentID section to another something I need to handle myself?

You can write in Ondrop method your jquery method for saving the sorted table in DB may be.

I used the jquery sortable to create a sortable list where as when you drag the rows the number updates as well, from there when you save the data it updates the database tables and returns the new results on the next page, would this be a suitable solution? May I assist with this issue?