Bjørn Zeiler
Bjørn Zeiler

Reputation: 97

Closing a simplemodal to open a new one

what I am trying to do is the following:

  1. Close the current open modal
  2. Open a new modal

This is proving annoyingly complicated (might be because I am not that much into jQuery and AJAX). I have a login modal and a register modal and currently when you click login you have an option to click "create account" which opens up a new modal. This all works fine but if you close the second modal (the create account one) it closes both modals (login and register) BUT it keeps a tinted and unclickale background as thought it only closed one of them. Is there a way to close the login modal first and then the register? I tried with $.modal.close() but that didn't seem to work. The way I did it was this:

$(".registerBtnClick").bind('click', function(){
    $.modal.close();
    $("#registerModal").bPopup({
        modalColor: ('#333'), 
        opacity: (.9), 
        closeClass: ('close')
    });
    return false
});

Any ideas? (Would be nice if you could be very specific as I, like I said, am not super great with jQuery.

Upvotes: 0

Views: 825

Answers (3)

Eric Martin
Eric Martin

Reputation: 2841

It may be the setTimeout in the current close function that is causing the issue. Try the following:

http://jsbin.com/aqavo3/edit

Upvotes: 2

danludwig
danludwig

Reputation: 47375

You can't do multiple / nested modals with simplemodal. You should close any open modals before opening a new modal.

If you want to open new modals from existing modals, look at jqModal, not simplemodal.

Upvotes: 1

Darren
Darren

Reputation: 11011

Have you tried passing the close as $('#registerModal').modal.close() and then add onClose callback to .bPopup to open the second one?

Look at the callbacks here for better reference: http://www.ericmmartin.com/projects/simplemodal/

Upvotes: 0

Related Questions