user328146
user328146

Reputation:

Problems with jQuery UI sortable and tables

I'm using jQuery UI sortable on a table.

My Javascript:

    $("#linksSortable tbody").sortable({
    handle  : '.handle', 
    //helper    : fixHelper,
    update  : function () { 
      var order = $('#linksSortable').sortable('serialize'); 
      //$("#info").load("ajaxtest.php?"+order); 
      alert(order);
    }
});

My table:

<table id="linksSortable">
    <tbody>
        <tr id="listItem_1"><td>1969</td><td>Slaughterhouse-Five</td><td>A+</td></tr>
        <tr id="listItem_2"><td>1952</td><td>Player Piano</td><td>B</td></tr>
        <tr id="listItem_3"><td>1963</td><td>Cat's Cradle</td><td>A+</td></tr>
        <tr id="listItem_4"><td>1973</td><td>Breakfast of Champions</td><td>C</td></tr>
        <tr id="listItem_5"><td>1965</td><td>God Bless You, Mr. Rosewater</td><td>A</td></tr>
    </tbody>
</table>

The sorting is working great, but when I want to get the order using the serialize function I'm getting this error in firebug:

uncaught exception: cannot call methods on sortable prior to initialization; attempted to call method 'serialize'

What am I doing wrong?

Upvotes: 4

Views: 9696

Answers (1)

user328146
user328146

Reputation:

Got it working.

It should be:

var order = $('#linksSortable tbody').sortable('serialize'); 

(of course..) thanks anyway :)

Upvotes: 3

Related Questions