JQuery drag, drop and save via cookie - how to?

Posted by RussP on Stack Overflow See other posts from Stack Overflow or by RussP
Published on 2010-05-11T12:21:42Z Indexed on 2010/05/11 12:24 UTC
Read the original article Hit count: 253

Filed under:
|
|

Sorry to be back folks, but you guys & girls seem to know much more about this than I do ... anyhow, here is my question/problem

I want to use drag, drop, sort (the interface plugin does me even though I have read it's out of date? but have looked at UI and to be honest is not clear and to me appears heavier than interface?)

Anyhow, how do I set a cookie to save positions from this:

$(document).ready(
function () {
    $('a.closeEl').bind('click', toggleContent);
    $('div.groupWrapper').Sortable(
        {
            accept: 'groupItem',
            helperclass: 'sortHelper',
            activeclass : 'sortableactive',
            hoverclass : 'sortablehover',
            handle: 'div.itemHeader',
            tolerance: 'pointer',
            onChange : function(ser)
            {
            },
            onStart : function()
            {
                $.iAutoscroller.start(this, document.getElementsByTagName('body'));
            },
            onStop : function()
            {
                $.iAutoscroller.stop();
            }
        }
    );
}

);

var toggleContent = function(e)
{
    var targetContent = $('div.itemContent', this.parentNode.parentNode);
    if (targetContent.css('display') == 'none') {
        targetContent.slideDown(300);
        $(this).html('[-]');
    } else {
        targetContent.slideUp(300);
        $(this).html('[+]');
    }
    return false;
};

var ser = function (s) {
    serial = $.SortSerialize(s);
    alert(serial.hash);
};

which is the "standard" interface demo, PLUS

How do I then get to read that cookie so that when I next visit the page the order is as I set it in the cookie?

Hopefully from that I can work out the rest .......?

Thanks for help in advance.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about drag-and-drop