Javascript to close Popup
Hithere!
Im trying to implement a JS script when any of the elements inside of a table of contents (Joli TOC) is clicked, the popup automatically closes. Here's the page:
5xprofit.com
I asked Gemini and it suggested something like this:
document.addEventListener("selectionchange", function() {
// Find the element containing the [joli_toc] shortcode
var tocElement = document.querySelector("[data-toc]");
// Check if element exists
if (tocElement) {
// Close the popup (assuming it has a class of 'toc-popup')
tocElement.classList.remove("active", "show"); // Common classes for popups
}
});
Can you help me?
-
Hi Alexander,
Thank you for reaching out to us.
We regret to inform you that custom development falls outside the scope of our support. We only provide support for Bizy's existing features. However, we recommend reporting this issue to the developers of Joli Table Of Contents as well, as they may be able to provide the additional help you need.
We apologize for any inconvenience this may cause and appreciate your understanding.
Best regards,
Ariel H.0 -
They mentioned this:
https://wpjoli.com/docs/joli-table-of-contents/developer-hooks/javascript-events/jtocclickedheading/I can embed it on the page but what is the element that needs to close?
0 -
document.getElementById('wpj-jtoc').addEventListener( 'jtocClickedHeading', ( e ) => console.log( 'JTOC CLICK', e ) );0 -
Hi,
Thank you for the update.
Making changes to the behavior of a third-party plugin is beyond the scope of our support. Please understand that our support is limited to Brizy Builder. Since the plugin already has the ability to disappear when you click outside of the TOC popup, we recommend reaching out to the plugin developers to request a feature that allows the popup to close when one of the items in the TOC is clicked. They should know how to implement this since it is their product.
Sorry for the inconvenience.
Best regards,
Ariel H.0
Please sign in to leave a comment.
Comments
4 comments