tags:

views:

13

answers:

0
$j("<%= @sortable_contents %>").sortable({
    connectWith: '.section-content',
    axis: 'y',
    zIndex: 1003,
    cursor: 'crosshair',
    update: function(){
        d = $j(".sections > li").map(function(index, element){
            return [$j(element).attr('id'),
                $j("#"+$j(element).attr('id') + " .content").map(function(subindex, subelement){
                        alert($j(subelement).attr('id'));
                    return $j(subelement).attr('id');
                })
            ]
        });
        alert(d)
              $j.ajax({
                type: 'post',
                data: d,//$j("<%= @sortable_contents %>").sortable('serialize'),
                dataType: 'script',
                complete: function(request){
                  $j('#sort_contents').effect('highlight');
                  },
                url: '/contents/sort_contents'})
              }
});

My server shows the parameters are

  Parameters: {"action"=>"sort_contents", "undefined"=>"undefined", "controller"=>"contents"}

Now, the commented out part worked... but it only worked for the first section (I have n lists I need to sort). <%= @sortable_contents %> is a placeholder for "#section1, #section2" or however many sections I have.

My problem is definitely with my variable d. I just don't know how to format it.

Its supposed to send a parameter like this:

"content" => 
[
 ["section1", ["item1", "item2"]],
 ["section2", ["item3", "item4", "item5"]]
]

UPDATE: changed data to

                data: {'content': d}

but then in my parameters I get "content"=>"[object Object]"