With jQuery I\'m retrieving positions of a sortable list using \'serialize\', like this:
var order = $(\'ul\').sortable(\'serialize\');
The vari
Solution
I have created my own solution by manipulating sortable('serialize'). I have simplified it by using jquery functions, and then posted it to php url for updating order of list in the database. Have a look at my code.
$( "#covercast_sortable" ).sortable({
update : function () {
var order = $('#covercast_sortable').sortable('serialize',{key:'string'});
// order var gives something like string=3&string=2&string=1
var ar = order.split('&');
var i = 0;
var str = '';
for(i;i<ar.length;i++){
if(str != "") { str += ','; }
// slice is used to remove 'sting=' from every value of var ar
str += ar[i].slice(7);
}
// here value of str is 3,2,1 with respect to order variable
$.ajax({
type: "POST",
url: 'myURL.php',
data: 'order=' + str,
cache: false,
success: function (data) {
console.log(data);
}
});
}
});
Cheers
var order = $('#projects ul').sortable('toArray'});
this might work too ;)