I have a simple jQuery script to show/hide list elements accordion-style along with a global boolean array to save which lists are shown/hidden. However, when switching from show/hiding different sublists, the boolean array goes undefined, ie (I call function with form_nav_links to show that list, then when I try to show help_nav_links right after, the array is undefined and requires an extra click). Can someone help me fix this? Here is what I have:
var listsOn = Boolean[2];
listsOn = [false, false];
var form_links = 0, help_links = 1;
function toggleView(subList) {
var i;
switch(subList){
case "form_nav_links":
i = form_links;
break;
case "help_nav_links":
i = help_links;
break;
};
if(listsOn[i]){
$("." + subList).slideUp(1000);
listsOn[i] = false;
}
else {
$("." + subList).slideDown(1000);
listsOn[i] = true;
}
Thanks in advance!
Boolean[2];in javascript means nothing useful.