• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Triggering a modal without using AJAX

Jake B.

Well-known member
#1
I have a modal that I want to display on a page, and I want it to be styled like any other modal in XenForo (member card, etc). However, I do not want the content to be loaded from another URL (so no creating a controller that outputs modal content and triggering a click on an OverlayTrigger to open this)

I need to be able to display it using JavaScript after a specific action has been completed, what is the best way to do this?
 

Daniel Hood

Well-known member
#3
Code:
XenForo.createOverlay(null, $(''
    + '<div class="xenOverlay">'
    +   '<div class="section">'
    +      '<a class="close OverlayCloser"></a>'
    +      '<h2 class="heading">Ay Jake!</h2>'
    +      '<div class="baseHtml">Sup?</div>'
    +   '</div>'
    + '</div>'
)).load();
 

Jake B.

Well-known member
#4
I believe I opened a modal without using Ajax in my Post Templates addon. You may want to look through the code. I can't atm unfortunately.
Code:
XenForo.createOverlay(null, $(''
    + '<div class="xenOverlay">'
    +   '<div class="section">'
    +      '<a class="close OverlayCloser"></a>'
    +      '<h2 class="heading">Ay Jake!</h2>'
    +      '<div class="baseHtml">Sup?</div>'
    +   '</div>'
    + '</div>'
)).load();
I'll have to give both of these a try once I get back to that project. Thanks!