jQuery Serialize List Plugin
During several recent projects I needed the ability to serialize an unordered list and pass it back to the server. A google search didn’t reveal much and I didn’t want to go digging this functionality out of larger plugins like sortable, UI, etc.
I decided to wrap it all up into a jQuery plugin so that it’s easier to use in different projects. The serialized un/ordered list may be sent back to the server, and for example in PHP, will be interpreted as an array.
You may use this plugin by simply calling it on your UL or OL.
$(document).ready(function(){
$('ul').serializelist();
});
You may download the most recent version directly from github:
This is fantastic, but with the string your plugin provides, how to do you handle that in the backend to insert the ordering in the database?
I’m using PHP on the backend which will properly convert the parameters into an array which I can then use internally. If your backend language doesn’t automatically convert that into a usable object or array, I’m sure there are code samples out there. Once it’s converted into an array, it’s just a matter of iterating over those elements.