multiple div panel slideup/slidedown cookie problem
i currently have 2 panels with information that have a link that when it is clicked it adds the class collapse and shrinks div and when collapse is clicked it expands the div.
- $(".collapse").live("click", function () {
- var header = $(this).parent(".header").attr('id');
- $(this).parent(".header").find('a').slice(0, 1).addClass("collapsed").removeClass("collapse");
- $(this).parent(".header").next(".panel").slideToggle("slow");
- $.cookie('customerinfo', 'collapse');
- $.cookie('header', header);
- return false;
- });
- $(".collapsed").live("click", function () {
- $(this).parent(".header").find('a').slice(0, 1).addClass("collapse").removeClass("collapsed");
- $(this).parent(".header").next(".panel").slideToggle("slow");
- $.cookie('customerinfo', 'collapsed');
- return false;
- });
im using Klaus Hartl's cookie plugin to store the current state of the link and and the id name of the header
which i then have this code which checks the state of the link and if its state is collapse then keep it hidden otherwise show.
- var leftCol = $.cookie('customerinfo');
- var currentheader = $.cookie('header');
- alert(currentheader);
- currentheader = '#' + currentheader;
- // Set the user's selection for the left column
- if (leftCol == 'collapse') {
- $(currentheader).find('a').slice(0, 1).addClass("collapsed").removeClass("collapse");
- //$(this).parent(".header").next(".panel").slideToggle(600).siblings("tr").slideUp("slow");
- $(currentheader).next(".panel").hide();
- //$('#customerinfo').css("display", "none");
- };
this currently only works with one panel at a time which is the problem i need it working with 5 panels checking on postbacks if a panel is expanded or collapsed. i had the idea of creating an array by adding the current header with the previous header cookie and storing it but im not that great with arrays and cant get it to work right. if anyone can help by giving some pseudo-code or giving a direction to go it would be greatly appreciated
heres the html
- <div class="header" id="header_customerinfo"> <a class="collapse">[-]</a> <a>Customer Information</a>
- <div class="button">
- <input type="button" value="text" />
- <input type="button" value="text" />
- <input type="button" value="text" />
- <input type="button" value="text" />
- </div>
- </div>
- <div class="panel" id="panel_customerinfo">
- <table id="tablea" class="stripes" runat="server" cellpadding="0" cellspacing="1">
- <tr>
- <td class="style1"> Customer ID: </td>
- <td><asp:Label ID="lblCustomerID" runat="server" />
- <asp:TextBox ID="txtCustID" CssClass="test" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator2" ControlToValidate="txtCustID" runat="server"
- ValidationExpression="^[0-9]+$" Text=" Must be numeric"></asp:RegularExpressionValidator></td>
- <td class="style1"> Entry Date: </td>
- <td><asp:Label ID="lblEntry" runat="server" />
- <asp:TextBox ID="txtEntry" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator1" ControlToValidate="txtEntry" runat="server"
- ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$"
- Text=" mm/dd/yy" /></td>
- </tr>
- <tr>
- <td class="style1"> Company Name: </td>
- <td><asp:Label ID="lblCompanyName" runat="server" />
- <asp:TextBox ID="txtCompanyName" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="regexTextBox1" ControlToValidate="txtCompanyName" runat="server" ValidationExpression="[\S\s]{4,50}"
- Text=" 4 characters min"></asp:RegularExpressionValidator></td>
- <td class="style1"> Status: </td>
- <td><asp:Label ID="lblStatus" runat="server" />
- <asp:TextBox ID="txtStatus" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator5" ControlToValidate="txtStatus" runat="server"
- ValidationExpression="^([a-zA-Z '/]+)$" Text=" invalid status"></asp:RegularExpressionValidator></td>
- </tr>
- <tr>
- <td class="style1"> Tax ID: </td>
- <td><asp:Label ID="lblTaxID" runat="server" />
- <asp:TextBox ID="txtTaxID" runat="server"></asp:TextBox></td>
- <td class="style1"> Removal Date: </td>
- <td><asp:Label ID="lblRemoval" runat="server" />
- <asp:TextBox ID="txtRemoval" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator3" ControlToValidate="txtRemoval" runat="server"
- ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$"
- Text=" mm/dd/yy" /></td>
- </tr>
- </table>
- </div>
- <div class="header" id="header_tustomerinfo"> <a class="collapse">[-]</a> <a>Customer Information</a>
- <div class="button">
- <input type="button" value="text" />
- <input type="button" value="text" />
- <input type="button" value="text" />
- <input type="button" value="text" />
- </div>
- </div>
- <div class="panel" id="panel_customerinfo">
- <table id="tablea" class="stripes" runat="server" cellpadding="0" cellspacing="1">
- <tr>
- <td class="style1"> Customer ID: </td>
- <td><asp:Label ID="lblCustomerID" runat="server" />
- <asp:TextBox ID="txtCustID" CssClass="test" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator2" ControlToValidate="txtCustID" runat="server"
- ValidationExpression="^[0-9]+$" Text=" Must be numeric"></asp:RegularExpressionValidator></td>
- <td class="style1"> Entry Date: </td>
- <td><asp:Label ID="lblEntry" runat="server" />
- <asp:TextBox ID="txtEntry" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator1" ControlToValidate="txtEntry" runat="server"
- ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$"
- Text=" mm/dd/yy" /></td>
- </tr>
- <tr>
- <td class="style1"> Company Name: </td>
- <td><asp:Label ID="lblCompanyName" runat="server" />
- <asp:TextBox ID="txtCompanyName" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="regexTextBox1" ControlToValidate="txtCompanyName" runat="server" ValidationExpression="[\S\s]{4,50}"
- Text=" 4 characters min"></asp:RegularExpressionValidator></td>
- <td class="style1"> Status: </td>
- <td><asp:Label ID="lblStatus" runat="server" />
- <asp:TextBox ID="txtStatus" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator5" ControlToValidate="txtStatus" runat="server"
- ValidationExpression="^([a-zA-Z '/]+)$" Text=" invalid status"></asp:RegularExpressionValidator></td>
- </tr>
- <tr>
- <td class="style1"> Tax ID: </td>
- <td><asp:Label ID="lblTaxID" runat="server" />
- <asp:TextBox ID="txtTaxID" runat="server"></asp:TextBox></td>
- <td class="style1"> Removal Date: </td>
- <td><asp:Label ID="lblRemoval" runat="server" />
- <asp:TextBox ID="txtRemoval" runat="server"></asp:TextBox>
- <asp:RegularExpressionValidator
- ID="RegularExpressionValidator3" ControlToValidate="txtRemoval" runat="server"
- ValidationExpression="^(((((((0?[13578])|(1[02]))[\.\-/]?((0?[1-9])|([12]\d)|(3[01])))|(((0?[469])|(11))[\.\-/]?((0?[1-9])|([12]\d)|(30)))|((0?2)[\.\-/]?((0?[1-9])|(1\d)|(2[0-8]))))[\.\-/]?(((19)|(20))?([\d][\d]))))|((0?2)[\.\-/]?(29)[\.\-/]?(((19)|(20))?(([02468][048])|([13579][26])))))$"
- Text=" mm/dd/yy" /></td>
- </tr>
- </table>
- </div>