Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Elementor loops in live search breaking with the ajax filters › Reply To: Elementor loops in live search breaking with the ajax filters
You are very welcome!
Oh, I’m sorry, I didn’t click that one, but the other ones, so I didn’t notice that.
Okay, that seems to be not hooked correctly and does not re-initialize. There is still hope, after running elementorFrontend.init() manually in the console it works again, so I guess all you need is a hook to do that after each search. This should do the trick:
/**
* Reinit Elementor after results are replaced
*/
add_action('wp_footer', function () {
?>
<script>
window.addEventListener("load", () => {
document.querySelectorAll(".asp_main_container").forEach((el) => {
el.addEventListener("asp_elementor_results", () => {
elementorFrontend.init()
});
});
});
</script>
<?php
});
Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.