Hi folks hope I someone can helps with something simple

In my rails project I have a jquery connected sortable that current
sends updates to a hidden field using ajax

$(function() {
            $("#sortable1, #sortable2").sortable({
                connectWith: '.connectedSortable',

                update:function(){
                    $.ajax({
                        data:$(this).sortable('serialize',{
                            key:'clients[]'
                        }),
                        dataType:'script',
                        type:'post',
                        url:'/users/selected_clients'
                    })
                }
            })
        });

the above code produces {"selected_clients"=>"89,46"} . However
updating a hidden field with data from a sortable element is something
I would prefer done on the client side, so I came up with this:

    $(function() {
        $("#sortable1, #sortable2").sortable({

            connectWith: '.connectedSortable',
            update:function(){
                var selected_clients = $(this).sortable('serialize',{
                    key:'clients[]'
                });
                $('#selected_clients').val(selected_clients)
            }
        })
    });

Although this does update the hidden field the value is formatted as
{clients[]=89&clients[]=46" }, which is too messy. I would like the
results to make that of the ajax serialized data. How might I fix
this?

Thanks for your help,

Josh

Reply via email to