Connect sortable lists together and update SQL using jQuery UI

Posted by rebellion on Stack Overflow See other posts from Stack Overflow or by rebellion
Published on 2010-03-22T07:39:47Z Indexed on 2010/03/22 7:41 UTC
Read the original article Hit count: 342

Filed under:
|
|

I'm using jQuery UI's sortable lists to sort items in a todo list, and the reordering of the lists works like a charm.

I have several UL lists for each todo category, i.e. Design, Development, etc.

I want to be able to move an item from one category to another, and jQuery UI's sortable lists plugin allows me to do this with the connectWith option parameter.

But I can't seem to find how to update the database as well. The todo database table has a field for a reference to the category which is laying in it's own table.

This is the current code:

$('.sortable').sortable({
    axis: 'y',
    opacity: .5,
    cancel: '.no-tasks',
    connectWith: '.sortable',
    update: function(){
        $.ajax({
            type: 'POST',
            url: basepath + 'task/sort_list',
            data: $(this).sortable('serialize')
        });
    }
});

Do I need to add another value to the AJAX's data parameter, or do the sortable plugin this for me in the serialize function?

© Stack Overflow or respective owner

Related posts about jqueryui

Related posts about sortable