2017-02-20 4 views
0

Ich habe ein Problem mit einem Modal, ich habe eine und wenn ich es schließe ich brauche etwas laufen, eigentlich, wenn es schließt, muss ich aktualisieren Sie die index.php.etwas tun, wenn Modal verbirgt

<!DOCTYPE html> 
<html> 
<head> 
    <script src="js/jquery.min_2.1.4.js"></script> 
    <script src="js/bootstrap3.3.min.js"></script> 
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" /> 

    <script> 

    $('#myModal').modal({ 
     'show': false 
    }); 


    $('#btnModal').click(function() { 

     $('#myModal').modal('show'); 
    }); 

    $('#myModal').on('hide', function(e) { 
     if (!confirm('You want to close me?')) 
     e.preventDefault(); 
    }); 
    </script> 

    </head> 
<body><!-- Button trigger modal --> 

<button type="button" class="btn btn-success btn-lg" data-toggle="modal" data-target="#myModal"> 
    Launch demo modal 
</button> 

<a role="button" class="btn" id="btnModal">Launch demo modal</a> 

<!-- Modal --> 
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 
    <h3 id="myModalLabel">Modal header</h3> 

    </div> 
    <div class="modal-body"> 
    <p>One fine body…</p> 
    </div> 
    <div class="modal-footer"> 
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> 
    <button class="btn btn-primary">Save changes</button> 
    </div> 
</div> 

</body> 
</html> 

Ich habe dieses Beispiel, und ich kann es nicht funktionieren. Jemand könnte mir helfen? Thks

Antwort

0

Bootstrap haben, ist es & versteckte Ereignisnamen angezeigt own:

on('shown.bs.modal',function() { ... })

on('hidden.bs.modal',function() { ... })

Hope this Hilfe. Viel Glück!

UPDATE: Mehr Bootstrap-modale Ereignisnamen:

show.bs.modal: Tritt ein, wenn die modale etwa ist
shown.bs.modal gezeigt werden: Tritt ein, wenn das modale vollständig angezeigt wird (nach CSS-Übergänge abgeschlossen haben)
hide.bs.modal : Tritt auf, wenn das Modal gerade ausgeblendet wird
hidden.bs.modal: Tritt auf, wenn das Modal vollständig ausgeblendet ist (nachdem CSS-Übergänge abgeschlossen wurden)

Weitere Informationen finden Sie in der Bootstrap-Dokumentation: http://getbootstrap.com/javascript/#modals-events

Verwandte Themen