0

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.

2
Contributors
2
Replies
12
Views
2 Years
Discussion Span
Last Post by bobgodwin
0

What was displayed on the console log? And what did you get in Ajax? Did you sort it before you pass to Ajax?

0

Sorry for the delayed reply. Turned out to be a corrupt database. All the logs come back ok. But the database would only half or randomly update.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.