I need to sort items from multiple columns. I use this to get the id from the columns and format the data:
$.fn.serial = function() {
var array = [];
var $elem = $(this);
$elem.each(function(i) {
var id = this.id;
$(move_selector, this).each(function(e) {
array.push( 'id[]=' + this.id );
});
});
var data = array.join('&');
//console.log(data);
return data;
};
$(function() {
$("div.connectedSortable").sortable({
connectWith: '.connectedSortable',
update: function(event, move_selector) {
$('#data').empty().html( $('.connectedSortable').serial() );
var datatest = $('#data').text();
//$('#test').text(datatest)
console.log(datatest);
}
});
});
This gets the data to the console.log but I can't seem to get it into a variable that I can use for the ajax request.
This kind of works:
$('#sub_butt').click(function(event){
var datatest = $('#data').text();
$.ajax({
beforeSend: bs,
complete: comp,
data: datatest,
type: 'POST',
url: subphp,
inline : true
});
event.preventDefault();
});
It can do this without the "connectWith" (With one column), but can't seem to do it with it.