Modal Javascript Trigger not working. Bug?

So i’m not sure why this isn’t working as I’m following the docs - https://theme.co/docs/toggleable#programmatically

Here you can see if you set a modal toggle like this the toggle is triggered so it shows the cross but doesn’t activate the modal. I’ve also tried not setting the variable and use the one that cornerstone gives. e.g. “e2-cs146” but no luck. As predicted the console logs gives a false followed by a true;

Can we check if this is a bug? Thanks

jQuery(document).ready(function($) {
  
  setTimeout(function() {
    console.log(window.xToggleGetState("my-toggle-id"));

    window.xToggleUpdate("my-toggle-id", true);
    
    console.log(window.xToggleGetState("my-toggle-id"));
  }, 1500);
  
});

Modal variable setup like this
image

Hi Sam,

Thanks for reaching out.
I would suggest you go through the following thread, which may help you open a modal by clicking a button.


Please remember that the above code will work if copied as it is and doesn’t conflict with any existing style.
Please note that the code provided serves only as a guide to help you get started 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 them in case they conflict with something on your site, nor will we enhance them. Further customization should be directed to a third-party developer or you can avail of One, where we answer the questions beyond normal theme support.

Thanks

Hi @tristup

Thanks. Yes this workaround did the trick.

jQuery(document).ready(function($) {

  setTimeout(function() {
    // Modal id = "my-toggle-id"
    $('#my-toggle-id-anchor-toggle')[0].click();
  }, 2500);
  
});

Can we check with a dev if the other method I mentioned in the first post is bugged?

Cheers

Great! We’ll have our developers check on this.
Thanks.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.