vodkabears / Remodal

No longer actively maintained.
http://vodkabears.github.io/remodal/
MIT License
2.75k stars 771 forks source link

Switch to new Modal from existing Modal #177

Closed pkarjala closed 9 years ago

pkarjala commented 9 years ago

I'd like to be able to have a link/button inside of an existing Modal that:

1) Closes the current Modal. 2) Opens a second, separate Modal.

I've been able to get this working using example doc and adding the following Script near the footer:

<script>
  var inst1 = $('[data-remodal-id=modal]').remodal();
  var inst2 = $('[data-remodal-id=modal2]').remodal();
</script>

And then adding the following in the Modal itself:

<button onClick="inst1.close(); inst2.open();">Test Jump</button>

Which results in:

<div class="remodal" data-remodal-id="modal" role="dialog" aria-labelledby="modal1Title" aria-describedby="modal1Desc">
  <button data-remodal-action="close" class="remodal-close" aria-label="Close"></button>
  <div>
    <h2 id="modal1Title">Remodal</h2>
    <p id="modal1Desc">
      Responsive, lightweight, fast, synchronized with CSS animations, fully customizable modal window plugin with declarative state notation and hash tracking.
<button onClick="inst1.close(); inst2.open();">Test Jump</button>
    </p>
  </div>
  <br>
  <button data-remodal-action="cancel" class="remodal-cancel">Cancel</button>
  <button data-remodal-action="confirm" class="remodal-confirm">OK</button>
</div>

The issue I'm encountering is that the "closed" state is never really reached when switching between the two, though perhaps that's intentional. Otherwise, it appears to work. Is there anything else I should consider using this method?

vodkabears commented 9 years ago

Hi!

Better solution:

<button data-remodal-target="modal2">Test Jump</button>

The issue I'm encountering is that the "closed" state is never really reached when switching between the two, though perhaps that's intentional.

Yes, right now it does not trigger the 'closed' event when swtching between two modals.

pkarjala commented 9 years ago

OK, this works much more clearly; thanks!

TheFrost commented 8 years ago

Hi! I have an issue with this in IE 11, I trigger the jump between modals and the last modal can't close or cancel, the class "remodal-opening" never change to "remodal opened", any suggestion about that?