Is it possible to get the serialized list of items from a UL in jquery by calling the serialize method directly instead of using a callback? The code snippet:
va
HTML
- Item 1
- Item 2
- Item 3
- Item 4
- Item 5
JQuery
$(document).ready(function () {
var updateOutput = function (e) {
var list = e.length ? e : $(e.target),
output = list.data('output');
if (window.JSON) {
output.val(window.JSON.stringify(list.sortable('serialize'))); //, null, 2));
} else {
output.val('JSON browser support required for this demo.');
}
};
$("#sortable1, #sortable2").sortable({
connectWith: ".connectedSortable",
update: function () {
updateOutput($('#sortable2').data('output', $('#json-output')));
},
}).disableSelection();
});
Result
"item[]=1&item[]=4&item[]=2"
Hope this help!