Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialize jquery sortable

I have been digging around on this site and googling for a while now and I cannot find a good solution to my problem. I would like to be able to save the state of my jquery portlets on a page. I would rather not have a "save state" button if I can avoid it.

Anyway, I just have the jquery code copied from their portlet example:

$(function() {
    $(".column").sortable({
        connectWith: '.column'
    });

    $(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
        .find(".portlet-header")
            .addClass("ui-widget-header ui-corner-all")
            .prepend('<span class="ui-icon ui-icon-minusthick"></span>')
            .end()
        .find(".portlet-content");

    $(".portlet-header .ui-icon").click(function() {
        $(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
        $(this).parents(".portlet:first").find(".portlet-content").toggle();
    });

    $(".column").disableSelection();
});

I have tried adding $(".column").serialize() and $(".column").sortable('serialize') and the same as above, but using $(".portlet") instead... I created a variable and set it to the value of the serialize method, but it returns nothing. What am I doing wrong?

Edit: Here is the code for column with a portlet inside:

 <div class="column" id="column_1">

<div class="portlet" id="portlet_1">

<div class="portlet-header">Times</div>
&nbsp Longest:
<div class="portlet-content">

<ChartFXGauge:DigitalPanel ID="LongestTimePanel" runat="server" >
</ChartFXGauge:DigitalPanel>
<p>
<a href="LongestORTime.aspx">(BySurgeon)</a>
</p>
</div>
</div>
</div>
like image 970
Jacob Huggart Avatar asked Aug 05 '26 02:08

Jacob Huggart


1 Answers

I ended up solving with this code:

$(".column").each(function() {
alert($(this).sortable("toArray"));
});

Which serializes each column instead of only the first column.

like image 126
Jacob Huggart Avatar answered Aug 06 '26 16:08

Jacob Huggart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!