Dynamically added elements to an accordion

Hello, I think that SiteJet Builder is a great instrument while building static websites. My use case is just little different 'cause I want to use object created within a sitejet web page and reuse against a json data bean.

I wrote the js code (not wiped at any deploy using a nginx virtual mapping) and included at the bottom of the page by an html block. This code take a json data bean and creates elements of an accordion (trigger and content) cloning the one built static into the page and wiped at the end of the script.

Perhaps, I dunno, there’s something I miss because the new elements generated and placed at the right place with new element ids calculated in order to not overlap with others don’t works and integrates with the logic of the accordion itself.

If you want to look at the page (the accordion is on the bottom of the page) you can visit Calendario - lab.dev.pallavolo.me

I repeat myself: It’s a very clever tool but I miss a way to reuse objects within the page dinamically.

Hey @Lucian_Dinu and @Imre_Fekete are you able to help with this?

Could you think a way to extend the use of your presets binding then to data fetched using apis?

Hey @Filippo_Adessi

The only way to add dynamic content and via an API would be our Collection feature, actually. Otherwise, there is no plan to dynamically add elements otherwise.

Have you tried that Collection feature already?

Nope! I have to review the “Collection feature” 'cause it’s the first time I read about. However I have developed my script which creates (cloning and appending after changing ids and accordion name into data-animation attribute) but nothing! Elements added by dynamically remain static even if there is no overlapping among them. You can see the last version here Accordion - lab.dev.pallavolo.me

Hey there,

Well, as I said, those dynamics are probably not realizable with the elements and if, that would exceed my / our support. So maybe the collection feature could really be a solution on the long run. :raised_hands:

Ok, Andre. I think the issue stays into applying CSS after the document has been fully loaded. I will apply my own accordion logic lo let it play smootly! :wink: Thank you for your support.

1 Like

Nice one! Enjoy :slight_smile: