April 29, 2012
Serializing Jquery-ui sortable with dynamically updated content
Question by nbu
I have a sortable list that updates my database when items are shifted around. However, there’s also a feature where users can add new items to the list dynamically. When these items are added, for some reason, sortable acts as if they don’t exist when updating the item positions in the database.
Is there a way to essentially serialize the sortable list after an item is added so it is essentially ‘live’ on the page?
I’ve looked into the .refresh()
code but that doesn’t seem to work…Thanks!
Answer by Starx
If simple enought, you can use the callback method of the adding sequence and update the database like that instead.
$("#newtab").appendTo("#sortableContainer", function() {
//OK its time to update this addition to the database
});