DragonByte is trying to add a JavaScript code to the “After Header” section in their theme component. However, the code only works when added to the “Head” or “Body” sections.
keegan explained that, according to the Discourse developers guide, script tags can only be added to three sections: </head>, Header, or </body>. Adding scripts to other sections, including “After Header”, will not work.
keegan also suggested that DragonByte try wrapping their script in an api.onPageChange function to make it work. However, DragonByte eventually found a solution in a separate Discourse thread, which can be found here.
This is simply not possible. Note, the developers guide mentions you have only three options for script tags to fire:
Is there a particular reason you need the code in the after_header? There may be other approaches you can take to achieve what you need.
When you tried separating the script in the head and the button in the after_header, are you sure the script is not firing at all, or is it that you are unable to select the button? It may be due to the way the Ember runloop is.