I'm getting the following error using the bootstrap lightbox from here:
Uncaught TypeError: data[option] is not a function bootstrap.js:1215
I've copied all files directory and haven't altered any parameters.
This is my code:
JS Linking:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="/js/bootstrap.js"></script>
<script src="/js/bootstrap-lightbox.js"></script>
<link rel="stylesheet" href="/css/bootstrap.css">
<link rel="stylesheet" href="/css/bootstrap-theme.css">
<link rel="stylesheet" href="/css/bootstrap-social.css">
<link rel="stylesheet" href="/css/bootstrap-lightbox.css">
<link rel="stylesheet" href="/css/font-awesome.css">
<link rel="stylesheet" href="/css/bootstrap-override.css">
<link rel="stylesheet" href="http://fonts.example.com/custom-font.css">
Gallery:
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Portfolio</h1>
</div><?php
$images = glob($_SERVER['DOCUMENT_ROOT'].'/img/gallery/*.{jpg,png,gif}', GLOB_BRACE);
$imageCount = count($images);
if($imageCount == 0) {
echo "There are currently no images in this gallery.";
}
else if($imageCount !== 0) {
$counter = 1;
foreach($images as $image) {
echo "<div class='col-lg-3 col-md-4 col-xs-6 thumb'> \n\r";
echo "<a data-toggle='lightbox' data-title='A random title' data-footer='A custom footer text' href='http://img.example.com/gallery/".basename($image)."' class='thumbnail'><img src='http://img.example.com/gallery/thumb.php?src=" . basename($image) . "&w=400&h=300&a=c' alt='Jolly Roger PCS Gallery Image' title='One Call Does It All' class='img-responsive'></a> \n\r";
echo "</div> \n\r \n\r \r\n";
}
}
?>
</div>
</div>
And the output of the gallery script for an image:
<div class='col-lg-3 col-md-4 col-xs-6 thumb'>
<a data-toggle='lightbox' data-title='A random title' data-footer='A custom footer text' href='http://img.example.com/gallery/10177464_1495074060751956_373648277891171115_n.jpg' class='thumbnail'><img src='http://img.example.com/gallery/thumb.php?src=10177464_1495074060751956_373648277891171115_n.jpg&w=400&h=300&a=c' alt='Jolly Roger PCS Gallery Image' title='One Call Does It All' class='img-responsive'></a>
</div>
And finally the JS at the end of page:
<script type="text/javascript">
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
event.preventDefault();
$(this).ekkoLightbox();
});
</script>
The script is working to an extent. When I click a thumbnail image the lightbox fires and the loading image appears, but the full size image of the icon never does.
The data-types all appear to be in the right spot so I don't know what is causing this error. I tried a search and didn't come up with any results.
The reason behind the error is incompatibility between versions of bootstrap and bootstrap lightbox plugin.
Check working demo here:
$(document).on('click', '[data-toggle="lightbox"]', function(event) {
event.preventDefault();
$(this).ekkoLightbox();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="https://unsplash.it/1200/768.jpg?image=251" data-toggle="lightbox">
<img src="https://unsplash.it/600.jpg?image=251" class="img-fluid">
</a>
If you are using bootstrap version 3.x.x then include the following assets:
If you are using bootstrap version 4.x.x then include the following assets: