【问题标题】:bootstrap-gallery, activating plugin on gallery containerbootstrap-gallery,在画廊容器上激活插件
【发布时间】:2014-10-09 21:32:55
【问题描述】:

我正在尝试在我的 rails 4 应用程序中使用 bootstrap-gallery

除了不理解是什么意思之外,我已经按照简单的说明进行操作:

3.  activate the plugin on the gallery container

$('.gallery').bootstrapGallery();

我试图将其添加到我的视图顶部:

<script>
$('.gallery').bootstrapGallery();
</script>

但是当我点击图片时 JS 似乎没有执行(我只是被带到图片 URL),并且我在 JS 控制台中收到以下错误:

Uncaught TypeError: Cannot call method 'hasOwnProperty' of undefined
Uncaught TypeError: Cannot call method 'addMarker' of undefined

指出我哪里出错了?

编辑:这是我的观点:

<%= javascript_include_tag "bootstrap-gallery" %>
<%= stylesheet_link_tag "bootstrap-gallery" %>

<div class="gallery row">
  <% @post.assets.each do |asset| %>
     <a class="col-xs-6 col-sm-4" href=<%= asset.asset.url(:medium) %>>
       <img src=<%= asset.asset.url(:medium) %> alt="">
     </a>
  <% end %>
</div>

<script>
var ready;
ready = function() {
  $('.gallery').bootstrapGallery();
};

$(document).ready(ready);
$(document).on('page:load', ready);
</script>

仍然遇到同样的问题:

Uncaught TypeError: Cannot call method 'hasOwnProperty' of undefined

【问题讨论】:

    标签: javascript ruby-on-rails twitter-bootstrap


    【解决方案1】:

    尝试:

    $('.gallery').bootstrapGallery({});
    

    由于某种原因,脚本期望将选项传递给它;如果您不需要更改任何内容,可以将选项设置为空。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多