persist node state between postbacks with jquery cookie plugin
<p>I have the following html table </p>

<pre><code>   &lt;table id="{64ED3A94-5833-4CC7-869F-CCE583B498BE}" class="ms-listviewtable"
            width="100%" cellspacing="0" cellpadding="1" border="0" 
            xmlns:o="urn:schemas-microsoft-com:office:office" dir="none"&gt;
       &lt;tbody id="tbod23-1__" isloaded="true" style="display: none;"&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-2__" isloaded="true" style=""&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-3__" isloaded="true" style="display: none;"&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-4__" isloaded="true" style=""&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-5__" isloaded="true" style="display: none;"&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-6__" isloaded="true" style="display: none;"&gt;&lt;/tbody&gt;
       &lt;tbody id="tbod23-7__" isloaded="true" style="display: none;"&gt;&lt;/tbody&gt;
    &lt;/table&gt;
</code></pre>

<p>This table is autogenerated by a sharepoint xsltlistviewwebpart (didnt post in sharepoint as the question is more jquery+html related). </p>

<p>this is a treeview with nodes, when i expand a collapsed node it changes style from </p>

<pre><code>style="display: none;" 
</code></pre>

<p>to </p>

<pre><code>style=""
</code></pre>

<p>The problem: the webpart does not remember which nodes were collapsed, so on each postback it resets all to expanded. What I need to do, is to remember the node state (expanded or collapsed) in a jquery cookie, and to retrieve it on postbacks (so, to persist the node state). </p>

<p>So far I got:</p>

<pre><code>&lt;script type="text/javascript"&gt;
_spBodyOnLoadFunctionNames.push("RememberClickedState");

function RememberClickedState()
{
var dv = $('.ms-listviewtable');
var items = [];
items = dv.find('tbody[id^="tbod"]');
$.cookie("itemListState", items);
    alert(items[0]);
    alert(items[1]);
 }

 &lt;/script&gt;
</code></pre>

<p>Can anyone please provide some pointers on how to do this. Im a bit dazed and confused about the events themselves, on page_load I should save the cookie but also retrieve it somehow. </p>

<p>Also "items" array stored all 7 elements which is good, but when i try alert(items[0]); I get undefined.  </p>

<p>Thank you</p>
