javascript - Removing modal content after closing -


mymodal displays image. after close, doesn't clear data previous modal. here have done far.

<a href="#mymodal" class="btn btn-default" data-toggle="modal" data-remote-image="resources/uploads/<?= $s->photo_url; ?>">     <i class="fa fa-image"></i> </a> 

modal body :

<div id="mymodal" class="modal fade" role="dialog">     <div class="modal-dialog">         <!-- modal content-->         <div class="modal-content">           <div class="modal-header">             <button type="button" class="close" data-dismiss="modal">&times;</button>             <h4 class="modal-title">slide</h4>           </div>           <div class="modal-body">            </div>           <div class="modal-footer">             <button type="button" class="btn btn-default" data-dismiss="modal">close</button>           </div>         </div>     </div> </div> 

javascript :

<script type="text/javascript"> $('#mymodal').on('show.bs.modal', function (e) {     $('<img class="img-responsive" src="'+ e.relatedtarget.dataset.remoteimage+ '">').load(function() {         $(this).appendto($('#mymodal .modal-body'));     }); });  $('#mymodal').on('hidden.bs.modal', function (e){      $(this).removedata(); }); </script> 

try:

$(this).removedata('bs.modal'); 

without seeing more of surrounding code hard tell. empty modal:

$('#mymodal .modal-body').empty() 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -