Button and modal

can i add buttons that will open modals?

Hi @barkmall,

Thanks for reaching out.
I would suggest you go through the following thread which may help you to achieve what you are trying to.



Hope it helps.
Thanks

not sure what’s wrong, can you help to take a look?

script -
jQuery(document).ready(function($){
$(’#lang-pop-up-btn’).click(function(){
console.log(‘1’);
$(’#lang-pop-up-anchor-toggle’).click();
console.log(‘2’);
});
});

no popup and can see log (https://staging-sellonbarkmall.kinsta.cloud/#)

Hi @barkmall,

There is nothing wrong with your code, but it depends on what you are trying to do here. I would suggest you go through the reference thread once and modify the code accordingly.

While intercepting any events on the a tag, you need to prevent the default action of that using the preventDefault function by using the following code.

jQuery('#lang-pop-up-btn').click( function(e)
{
    e.preventDefault();
});

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 that means we can’t fix it in case it conflicts with something on your site nor will we enhance it.

Thanks

thanks for the reply. I have added the prevent function now.

I can see that actually my code do trigger the click event, but somehow the popup just doesn’t show up. I can even see the hamburger icon -> ‘X’ transformation animation. Do you have any idea?

Hi Mei,

Actually, you don’t need the custom script, please remove it to avoid conflict. There is a Toggle Hash option on the Modal element, which you can use to deeplink or bind the Modal with a Button element.

So if your Toggle Hash is modalhash, then your button URL should be #modalhash

Hope it helps,
Cheers!

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