Toggling a Content Area Modal from another button

Hi,

I have a content area modal set up (modal A), and I’m wondering if there’s a way to add a separate button or link that could invoke opening of modal A.

Thanks,
Matt

Hey Matt,

Yes, there’s a way. Use the Toggle Hash option of the Content Modal as suggested in this other thread: Can Content area modal be active on page open?

Hope that helps.

Can you elaborate? Not sure I was able to apply instructions from that thread correctly.

So, content area modal… On another part of page, I have a button or link. Goal is to have that separate button toggle open the content area modal. I added toggle hash “togglemodal” and then on button, the link is #togglemodal - or at least that was my understanding. Didn’t seem to do anything.

Edit: It works! Only issue now is the button invokes the modal the first time, but if I x out of the modal and try button again, it doesn’t open. The actual toggle on the content area modal continues to work. So that’s where I’m at.

Thanks for the help!

Hi @mmelton12,

I am able to confirm the issue. I will add this to our issue tracker for now. We’re sorry for the inconvenience this has cause you. Thank you for understanding.

Oh hey! I caught a bug. No worries. Any ideas on an (unsupported) workaround? Can it be accomplished with some jquery and css?

Hi @mmelton12,

It’s actually more of a feature request, the toggle hash is for the address bar’s hash and it has no direct connection to the button. It only triggers the modal since the button changes the address bar’s hash upon the first click.

There is a workaround, while that is outside the scope of support, I could point you in the right direction with the understanding that it would ultimately be your responsibility to take it from here.

See the jQuery .on(click) event and .trigger() event, thats almost plain English (on button click, trigger modal) :slight_smile:

Cheers!

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