views:

5

answers:

0

I'd like to customize jquery treeview plugin to support cookies on nested ULs. I extracted the piece of code that needs to be customized but I am having problems getting it to work.

function serialize() {
    function binary(arg) {
        return arg ? 1 : 0;
    }
    var data = [];
    branches.each(function(i, e) {
        data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0;
    });
    $.cookie(settings.cookieId, data.join(""), { path: '/' } );
}

function deserialize() {
    var stored = $.cookie(settings.cookieId);
    if ( stored ) {
        var data = stored.split("");
        branches.each(function(i, e) {
            $(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ]();
        });
    }
}




<ul>
    <li><a href="#">1</a>
        <ul>
            <li><a href="#">1.1</a>
                <ul>
                    <li><a href="#">1.1.1</a></li>
                    <li><a href="#">1.2.2</a></li>
                    <li><a href="#">1.2.3</a></li>
               </ul>
           </li>
           <li><a href="#">1.2</a></li>
           <li><a href="#">1.2</a></li>
       </ul>
    </li>
    <li><a href="#">2</a></li>
    <li><a href="#">3</a></li>
</ul>