Skip to content

Instantly share code, notes, and snippets.

@krugazul
Last active April 18, 2019 04:01
Show Gist options
  • Select an option

  • Save krugazul/e5eb0e9cd618e6fbc92ffb8005864e97 to your computer and use it in GitHub Desktop.

Select an option

Save krugazul/e5eb0e9cd618e6fbc92ffb8005864e97 to your computer and use it in GitHub Desktop.
jQuery - Load an iframe on Bootstrap Modal Shown
jQuery(document).ready(function() {
jQuery("#videoModal").on('shown.bs.modal', function(){
jQuery('#videoModal iframe').attr('src', jQuery('#videoModal iframe').attr('data-src') );
});
});
<?php
/**
* The video html
*/
<a href="#videoModal" target="_self" class="lsx-button" rel="noopener noreferrer" data-toggle="modal">Watch The Video</a>
<div class="modal fade" id="videoModal" tabindex="-1" role="dialog" aria-labelledby="videoModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<iframe width="100%" height="600" data-src="{url}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>
</div>
</div>
</div>
</div>
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment