Hi Henry,
You can obtain the section text with the following code in the "On Selection Changed" event of the Accordion component:
var mySectionKey = me.getExpandedKey();
var mySectionText = me.getSectionText(mySectionKey);
However, there appears to be a limitation in that if an item in the default section (first section) is selected, a null section key is returned unless the user explicitly selects and expands the first section again. You could raise this in the Community Repositories Issues.
In the meantime, a workaround would be that when you load the contents of the Accordion, include the parent key in the items (with a separator) something like this:
ACCORDION_1.addElement(parentKey, parentKey + "|" + key, text, url);
Then include the following code in the "On Selection Changed" event of the Accordion component:
var myItemKey = me.getSelectedKey();
var myItemKeyArray = myItemKey.split("|");
var mySectionKey = myItemKeyArray[0];
var mySectionText = me.getSectionText(mySectionKey);
An alternative to the above workaround would be to obtain the JSON structure of the sections at startup with the getSectionsAsJSON() method and then lookup the parent section by parsing the JSON in the "On Selection Changed" event script.
Regards,
Mustafa.