【发布时间】: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