Search
Other Modals questions
Forum

Close modal on clicking text link

M. Stiekema's Avatar M. Stiekema
Hi Peter,

We have a modal with a text link (anchor) in the pop-up <a data-link-type="anchor" href="#aanmelden"> and the anchor works fine, but the modal must be closed with the same click on that link. Is there a way to do this in the source code in the article?

See: 05.bluepoint-concept.nl/service/trainingen and click on "Lees meer" of "Basis training InDesign"

Regards,
Michiel
M. Stiekema's Avatar M. Stiekema
Hi Peter,

Unfortunately this does not work. I've tried different things, but it doesn't work. I have put in the exact code from your example... I get a popup with button, but the button does nothing.

{modal content="close-my-modal" closebutton="false" overlayclose="false" esckey="false"}Modal with a custom Close Button{/modal}
{modalcontent close-my-modal}
<p>You can only close this modal with this button:</p>
<p><a class="btn btn-danger" onclick="jQuery.rl_modals.close();">Close this Modal</a></p>
{/modalcontent}

Hope you have a solution for this...
Regards,
Michiel
Peter van Westen's Avatar Peter van Westen ADMIN
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
M. Stiekema's Avatar M. Stiekema
Yes... on this page: 05.bluepoint-concept.nl/service/trainingen
If you need backend credentials, just let me know.

Regards,
Michiel
Peter van Westen's Avatar Peter van Westen ADMIN
It looks like you are using the Joomla 4 version of Modals, which is still in full development and not ready for (production) use yet.
It is fine to test it out. But things can and will still change before release.
Please post a rating at the Joomla! Extensions Directory
M. Stiekema's Avatar M. Stiekema
Yes, that's right... too bad it doesn't work (yet). Do you have a good alternative that you can recommend? Of course temporarily, because the RegularLabs extensions remain our preference 😉

Michiel
Peter van Westen's Avatar Peter van Westen ADMIN
I don't know of a different modals solution for Joomla 4.

I am trying to finish Modals before the end of the year.
If you use the latest dev version, you can do:
onclick="RegularLabs.Modals.close();"
Please post a rating at the Joomla! Extensions Directory
M. Stiekema's Avatar M. Stiekema
Thanks Peter...I'll trie this later today!
Michiel
M. Stiekema's Avatar M. Stiekema
Well....
I've installed the latest development release (Modals-v11.11.2-dev2510358-PRO) and made a test article: 05.bluepoint-concept.nl/service/test-modal

But no modal popup anymore at all 😉

Code in the article (2 modals):
<p>{modal content="close-my-modal"}Modal with a custom Close Button{/modal} {modalcontent close-my-modal}</p>

<p>You can only close this modal with this button:</p>

<p><a class="button" onclick="RegularLabs.Modals.close();">Close this Modal</a></p>

<p>{/modalcontent}</p>

<p>&nbsp;</p>

<p>{modal html="This text is entered right inside the modal tag." title="Hello!"}Show some inline text{/modal}</p>
Peter van Westen's Avatar Peter van Westen ADMIN
Please use the new dev version...
regularlabs.com/development-releases
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
Also, I recommend changing your button code to something like:
<button type="button" class="btn btn-danger" onclick="RegularLabs.Modals.close();">Close this Modal</button>
Please post a rating at the Joomla! Extensions Directory
M. Stiekema's Avatar M. Stiekema
Ok... something is working now 😉
When I put this in: <a class="button" href="/service/trainingen" onclick="regularlabs.modals.close()">
The modal will close and the page refreshes... to another page also works fine.

BUT... I don't get it to link to an anchor yet. Tried these codes:
<a class="button" data-link-type="anchor" href="#aanmelden" onclick="regularlabs.modals.close()" target="_self">
<a class="button" data-link-type="anchor" href="/service/trainingen#aanmelden" onclick="regularlabs.modals.close()" target="_self">
<a class="button" data-link-type="anchor" href=" 05.bluepoint-concept.nl/service/trainingen#aanmelden " onclick="regularlabs.modals.close()" target="_self">
The anchor works...because it is scrolling down... but it won't close 😉

Examples are on 05.bluepoint-concept.nl/service/trainingen (first 2 columns)

Regards,
michiel
Peter van Westen's Avatar Peter van Westen ADMIN
It is case sensitive.
RegularLabs.Modals.close();
Not:
regularlabs.modals.close();
Please post a rating at the Joomla! Extensions Directory
Peter van Westen's Avatar Peter van Westen ADMIN
PS: When creating a link that opens a different page, you don't really need to have it also close the modal.
The loading of the new page will mean the modal is gone.
Please post a rating at the Joomla! Extensions Directory
M. Stiekema's Avatar M. Stiekema
Aha... so simple 😉
Works great now...thanks!!
Peter van Westen's Avatar Peter van Westen ADMIN
The first beta version is now available.
See: regularlabs.com/forum/modals/49985-modals-for-joomla-4
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription