I've created a new input filter, that allows users to embed an entity (think node) into a post using bb tags (for example inserting the code [node:456] into the body would replace the code with the rendered node #456). Input filters are run only once, and the result is cached. So if I add javascript in the input filter, it is only ever called if the page is viewed at the same time as the filter output is cached, and not on subsequent viewings of the code.
I need to add a javascript file every time the output from the bb tag is outputted on the site. I don't actually think there is a way to do this, and I'll have to come up with some other solution, but I'm wondering if someone has a way of ensuring the JS is added even when the result is cached. Thoughts?
Comments
I have created a input filter
I have created a input filter which convert a shortcode to a custom slider. I am facing the same issue with input filter. But I wonder, it was working before perfectly. Some of node still working but no new node working.
You can't add JS in an input
You can't add JS in an input filter, because the filter caches the text and the function is never called again until the cache is next cleared.
Contact me to contract me for D7 -> D10/11 migrations.
@Jaypan: Thank you for reply.
@Jaypan: Thank you for reply. I have added js in tpl file with some settings. Now It is working perfectly.