drb0901500211 2016-09-27 22:05
浏览 135
已采纳

未捕获的TypeError:data [option]不是函数bootstrap.js:1215

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'> 
";
         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> 
";
         echo "</div> 
 
 
";
         }
       }
    ?>
  </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.

  • 写回答

2条回答 默认 最新

  • dsizmmwnm56437180 2016-10-05 06:06
    关注

    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:

    enter image description here

    If you are using bootstrap version 4.x.x then include the following assets:

    enter image description here

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Pwm双极模式H桥驱动控制电机
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题