The problem I am now working on is a vanilla js minirouter that loads templates from ‘views’ and inserts them to the respective div in the dom tree. The problem is, after injecting the partial template into the layout, due to asynchornous nature of AJAX, it loses binding to both scripts and the general dom events manipulation.
I tried a silly way like using eval() function after successful AJAX call that evaluates inline script in the bottom of the partial template, but it is way too messy.
What’s the alternative? I was thinking about firing a CustomEvent to stimualte bubbling up the tree again after the AJAX call.
A simple example as that, now trying to manipulate home template elements after javascript injection into the front section and it would not catch what I targeted.
So, the problem here is, in order to target ‘element’ i’d have to put it either inside ajax successful response call (realy messy), or include additional DOM manipulation script in the bottom of the home.html partial which would not work as those are not evaluated after AJAX call without using eval() on the inline scripts, and inline scripts are a mess.