1

I use Joomla modal to popup an internal link.

JHTML::_('behavior.modal');
<a class="modal" href="contact-us.html" rel="{size: {x: 480, y: 500}, handler:'iframe'}">Contact Us</a>

I don't want to close the popup window when I click the background. Does anyone know how to prevent the modal closure on that user event?

2

Just a note that behavior.modal uses Mootools and has been removed in Joomla 4, so I'd suggest using bootstrap.renderModal instead, which will ensure J4 compatibility.

HTML:

<button type="button" data-toggle="modal" data-target="#contactModal">Contact Us</button>

PHP:

use Joomla\CMS\HTML\HTMLHelper;

echo HTMLHelper::_(
    'bootstrap.renderModal',
    'contactModal',
    [
        'url'        => 'contact-us.html',
        'title'      => 'Contact Us',
        'backdrop'   => 'static',
        'modalWidth' => 40,
        'bodyHeight' => 60,
        'footer'     => '<a type="button" class="btn btn-secondary" data-dismiss="modal">Close</a>'
    ]
);

Note that 'backdrop' => 'static', will prevent the modal closing when clicking the background.

2
  • I'm using Joomla 3.9.x, how to do it in Joomla 3.9?
    – zhang
    Nov 16 '20 at 5:09
  • The above is for Joomla 3.9
    – Lodder
    Nov 16 '20 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.