This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

JS event on search results returned

Home Forums Product Support Forums Ajax Search Pro for WordPress Support JS event on search results returned

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #57006
    yannik_ozA2yannik_ozA2
    Participant

    Hey there, I checked the forum but couldn’t find anything about that, so I’m asking by myself.

    Is there a way to trigger a custom js function after the search results are loaded depending on the search? I’m using Divi – don’t know if this is important at this point?!

    Would be nice, if that’s possible 🙂

    #57007
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    Yes – it is possible through the JS API 🙂

    This is what you are looking for:

    window.addEventListener("load", () => {
    	document.querySelectorAll(".asp_main_container").forEach((el) => {
    		el.addEventListener("asp_results_show", (event) => {
    			// event.detail carries the arguments
    			const [id, instance, phrase] = event.detail;
    			console.log(id, instance, phrase);
    		});
    	});
    });

    I hope this helps!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.