Hello,
What I’m trying to do is open a modal window on page load when a particular ACF data type is present. If ACF data type Emergency is set I want to output a modal window (see attached png in secret note) with Emergency details and open that by default. I have tried to cannibalize another modal and set some custom id and class names then trigger the modal on load with : document.addEventListener('DOMContentLoaded',()=>{ alert('yep'); window.xToggleUpdate('emergency-event-modal', true); });
It isn’t working but I think this is close. The short code that dumps the modal markup with emergency details is working. I just need to launch that modal on pageload.
Thanks for reaching out.
You need to add the Toggle Hash to the Modal element, as described in the following thread, and trigger that on document.ready instead of any other event to load the modal on pageload.
jQuery(document).ready(function($) {
//add your code here
});
Please remember that the above code will work if copied as it is and doesn’t conflict with any existing code.
Please note that the code provided serves only as a guide to help you get started with custom coding on your own if there’s no option offered in our theme or the products we bundle.
We really do not provide support for custom codes, which means we can’t fix it in case it conflicts with something on your site, nor will we enhance it. Further customization should be directed to a third-party developer, or you can avail One, where we answer the questions beyond normal theme support.
NOTE: Please remember that the code needs to be added to the JavaScript file, and ACF data must pass through the localize script to that specific JS file.
Setting a cookie because I only want the modal alert to be triggered once. I dont’ understand why the jquery click isn’t triggering the modal. Entering jQuery('#emergency_alert-anchor-toggle')[0].click(); in the browser console will trigger the modal.
I’ll leave it here in a secret note but I don’t think you’ll be able to reach the site as the firewall will likely filter out traffic from outside the US.
I tried to access the given site URL, but it is not accessible. I tried with the VPN, but it is not accessible on my end. I would suggest you please disable the IP restriction so we can check it on our end.
Unfortunately, your website still can’t be accessed and is showing the This site can’t be reached error. It seems that IP restrictions are added here. I would suggest you deactivate the IP Restriction and let us know for further assistance.
Please remember that we are from different parts of the world, and most of us have a dynamic IP, so we can’t provide a specific IP address to you for whitelisting.