treehouse : what would you like to learn today?
Web Design Web Development iOS Development

I want to display jQuery sortable order from a cookie

  • Hi,

    I have a jQuery sortable area where a user can move widgets to different positions in a grid style layout.
    I have managed to save the sort order to a cookie once the user is finished moving stuff around.

    I now want to set the display order to reflect the order in the cookie.

    All ideas would be much appreciated.

    	//Create MYAREA sortable widgets  
    $( "#myarea" ).sortable({
    start: function( event, ui ) {
    ui.placeholder.height(widgetHeight['myarea']);
    },
    // SET Cookie to save sortable order
    update:function(event, ui) {
    var order = $( "#myarea" ).sortable("toArray").join();
    $.cookie("MYAREAORDER",order);
    },
    stop: function( event, ui ) {
    setWidgetDisplay('myarea');
    }
    });
    $( "#myarea" ).disableSelection();


    So I have a cookie called MYAREAORDER with its value "#id1,#id2,#id3#id4..."