saving button state in jquery
<p>I am using a few custom jquery buttons with <code>datatables</code> to do some sorting. Unfortunately when I leave the page and come back, <code>datatables</code> remembers its state, but the toggle button doesnt. So I am trying to set a cookie when the button is toggled so I can read it later, but I cant seem to get it working.</p>

<p>Here is my button code with the cookie creation:</p>

<pre><code>$('#completed_button').bind('change', function(){
  if($(this).is(':checked')){
    $(this).button('option', 'label', 'Hide Completed');
    oTable.fnFilter('Completed',6,false);
    $.cookie('showCompletedState', 'checked');
  } else {
    $(this).button('option', 'label', 'Show Completed');
    oTable.fnFilter('',6,false);
    $.cookie('showCompletedState', 'unchecked');
  }
});
</code></pre>

<p>Now here is my attempt at reading the cookie and setting the button state:</p>

<pre><code>var showCompletedState = $.cookie('showCompletedState');
if (showCompletedState == 'checked') {
    &lt;-- need something here to actually change button state --&gt;
    $('#completed_button').button('option', 'label', 'Hide Completed');
    oTable.fnFilter('Completed',6,false);
} else if (showCompletedState == 'unchecked') {
    &lt;-- need something here to actually change button state --&gt;
    $('#completed_button').button('option', 'label', 'Show Completed');
    oTable.fnFilter('',6,false);        
}
</code></pre>
