List / Accordion

I think the Accordion feature of a LIST fits my application needs, but I’m not sure how to get/do everything I need. I’m essentially presenting an outline of items as in your DOCS example. In my case, I need to associate a URL with the items at the deepest level, such that when that “tab” is selected, I can issue a “ZGO” for that URL. So, can I / how would I store that data in the list parameter object, and how would I reference it when the relevant tab is selected (as in the “.tap” function in the DOCS example).

Hi Jonathan! The List does not store any data aside from an index number and a text value. So you could store the urls in an array matching the index number or in an object literal matching the text value (if it is unique). For an accordion, there are going to be some indexes or text values that do not have a url associated but it will still work out.

So, prepare the array like

const urls = [null,"https://zimjs.com", "https://danzen.com", etc] 
// assuming the 0 index is a parent menu, etc.and on tap use 
if (urls[list.accordionIndex]) zgo(urls[list.accordionIndex]);

Or if wanting to do it based on the text:

const urls = {"ZIM":"https://zimjs.com", "Dan Zen":"https://danzen.com"}
// and in the tap use 
if (urls[list.value]) zgo(urls[list.value]);

That was the info I needed. Thanks.

1 Like