I have j/s in my theme (am I infamous yet? ;) which is modifying the DOM by adding elements via api.decorateCooked(…. It inserts a variety HTML head elements.
I also have the DiscoTOC Theme component installed.
However, adding the usual <div data-theme-toc="true"> </div> that DiscoTOC notices and expands, doesn’t generate a table-of-contents including my dynamically inserted elements.
I’m figuring this might be as simple as execution order… if DiscoTOC looks before my j/s adds more elements . . .
What determines the ordering of execution if multiple bits of theme j/s code are calling api.cooked(?
I’m inserting within the post, yes. That’s why I suspect execution order.
Some bit of code determines the execution order… that’s the leverage point for me to get my component before TOC. eg, if it’s alpha by component name (ie, as displayed in the Component list in Admin area) then I can try namin my component accordingly, etc
That said, you can set initializer order for advanced use cases. I can put DiscoTOC in a named initializer so you can run your code before DiscoTOC, but I need to know what you’re trying to do first to give you a clear answer.
Your modifications here are based on an HTTP/AJAX request, correct?
Yes AJAX, but using a synchronous call. (I’ve always loved the oxymoron of synchronous AJAX :^)
I’m feeling like my next step is create a proper component—atm, it’s just some j/s pasted into my Theme’s Header. Then I can try fiddling with a judiciously chosen ID. “_foo” or “0-foo” might be all I need.