Seems to be an incompatibility between the persistence option and the default expand option.
If persistence is on, the values to persist are apparently stored as a string.
the following line appears to deal with this
Code:
// var expandedindices=ddaccordion.urlparamselect(config.headerclass) || ((config.persiststate && persistedheaders!=null)? persistedheaders : config.defaultexpanded)
var expandedindices=ddaccordion.urlparamselect(config.headerclass) || (config.defaultexpanded)
if (typeof expandedindices=='string') //test for string value (exception is config.defaultexpanded, which is an array)
expandedindices=expandedindices.replace(/c/ig, '').split(',') //transform string value to an array (ie: "c1,c2,c3" becomes [1,2,3]
but according to my observation, it doesnt work exactly as advertised - in fact it transforms the string into an array of strings. ie: "c1,c2,c3" becomes ["1","2","3"].
this seems to be the intended outcome since down here:
Code:
if (jQuery.inArray(index+'', expandedindices)!=-1){ //check for headers that should be expanded automatically (convert index to string first)
you deliberate convert the needle into string form... however... as the previous comment notes, config.defaultexpanded is an array of numbers... and there's nothing in this area of code to convert it to an array of strings? so if persistence is switched off/empty, expandedindices becomes an array of ints not an array of strings/
and therefore
Code:
if (jQuery.inArray(index+'', expandedindices)!=-1)
means we are trying to find a string in an array of ints; so when config.defaultexpanded is [1], expandedindices becomes [1], whereas with that coercion-to-string on index, we end up looking for "1" is in the array [1]. Which obviously always fails, and therefore I get no default expanded.
Solution, since I dont need persistence:
first line quoted above changes to:
var expandedindices=ddaccordion.urlparamselect(config.headerclass) || (config.defaultexpanded)
so that expandedindices always sticks with numbers. leaving the persistence stuff in the ternary seemed to override config.defaultexpanded, and make it turn into strings storing "expand nothing" magic value or something like that - not only even when I set persist to false in the init config, but even when I deleted the cookies so there should have been nothing to persist regardless... i donno, didnt look into this too hard, was easier just to get rid of it.
then second line changes to:
if (jQuery.inArray(index, expandedindices)!=-1){ //check for headers that should be expanded automatically (dont convert index to string first as it makes it not work)
I guess there would be a way of fixing this without ripping out persistence completely, by converting the defaultexpanded array to an array of strings, but this works for me, so I stopped there.
Bookmarks