I am trying to get some elements of a partial whenever it is rendered. The problem is that I can use document.addEventListener('DOMContentLoaded', () => {}); when the whole page is rendered but I am not able to figure out how to get the elements everytime the html partial is rendered.
js code
window.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('answer_choices');
});
How can I call this event whenever the partial is rendered. I can include the javascript file in the partial itself but it creates a lot of overhead. So this javascript file is included in the main html file but I want the querySelectorAll function to be triggered whenever the html partial is rendered. How can I do the same?