MyBB Community Forums

Full Version: Using MyBB.popupWindow
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello there !

I'm trying to understand how to use the MyBB js functions, but I fail.

I want to use MyBB.popupWindow to simply open a modal popup (for the imgur plugin next version), so I did:

In my imgur_popup template:
<div class="modal">
  <div style="overflow-y: auto; max-height: 400px;" class="modal_{$pid}">
    <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
  <td class="thead">Test imgur</td>
      </tr>
      <tr>
        <td class="tcat">This is a test</td>
      </tr>
    </table>
</div>
</div>

The button is:
<a href="/misc.php?action=imgur" onclick="MyBB.popupWindow('/misc.php?action=imgur&popup=true&editor=MyBBEditor'); return false;">{$lang->imgur_open}</a>

And when I click my button, my popup content is added in the page but not showed (class modal is hidden).
I can't understand why it works fine for existing popups (smilies, buddylist, ...) and not for this.

Did I miss something ? I don't find any particular code for the smilies popup, but I'm sure there is one to do the modal:open...

Thanks by advance.

Regards,
CrazyCat
this guidance might help => Using MyBB Modals (see also some responses there)
Thanks .m.,
I'd already read it, and I was looking for a simpliest way with a MyBB native function.

I'll follow this tutorial and adapt it.
^ simple method is already available in the suggested guidance thread (in a reply) and here is an example
Ok, I think I can now manage with the modal Smile

Thanks a lot
Back with this subject...

I now well open my modal and use it, but I dislike the way I close it.
It has to be automaticaly closed on a ajax success, the only way I found to do that working is:
$('.modal').remove();
$('.jquery-modal.blocker').remove();
$('body').css('overflow', 'auto');

Is there a simpliest way to close it ?
(2015-06-18, 08:51 AM)Crazycat Wrote: [ -> ]Back with this subject...

I now well open my modal and use it, but I dislike the way I close it.
It has to be automaticaly closed on a ajax success, the only way I found to do that working is:
$('.modal').remove();
$('.jquery-modal.blocker').remove();
$('body').css('overflow', 'auto');

Is there a simpliest way to close it ?

more simpliest is using
$.modal.close();
... So simple...

Thanks martec !