Close modal in the REMODAL plugin

Asked

Viewed 188 times

1

I’m using the Vodkabears Remodal plugin,

https://github.com/VodkaBears/Remodal#readme

I open a modal with it and inside the modal I have an iframe, I wanted to know how I close the modal from a button inside the iframe?

HTML of Modal:

<div class="remodal" data-remodal-id="modal" data-remodal-options="closeOnAnyClick: false, closeOnEscape:false" style="width: 700px; height: 700px;">
    <h1>Galeria</h1>
    <iframe src="galeria.html" frameborder="0" height="550" width="600"></iframe>
</div>

HTML from the gallery.html

<!doctype html>
<html lang="pt-Br">
<head>
<meta charset="UTF-8">
<title>Galeria de Produtos</title>
<link type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body style="background-color: transparent;">
<div class="container">
<div class="row">
    <div class="col-xs-4">
        <img src="foto.jpg" alt="" class="thumbnail"/>
        <input type="button" value="Fechar Modal" class="btn btn-primary"/>
    </div>
</div>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

1 answer

0


You don’t indicate how you’re instantiating remodal, but you can deal with your problem as follows:

// instanciar remodal
var inst = $.remodal.lookup[$('[data-remodal-id=modal]').data('remodal')];

// abrir modal
inst.open();

// detetar clique para fechar modal
var iframe = $('#idDaIframe').contents();

iframe.find("#idDoBotao").click(function(){
    inst.close();
}); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.