[英]PhotoSwipe, Rails, Coffee doesn't work at all
Can't understand why PhotoSwipe doesn't show anything when I'm trying to add it into Rails project无法理解为什么 PhotoSwipe 在我尝试将其添加到 Rails 项目时不显示任何内容
Code I wrote:我写的代码:
<body>
<!-- some Rails and other stuff -->
<%= render 'shared/photoswipe' %>
</body>
shared/_photoswipe.html.erb contains full copy of div class="pswp" from 2) Invisible div successfully added at the end of page shared/_photoswipe.html.erb 包含 div class="pswp" 的完整副本 2) Invisible div 在页面末尾成功添加
Added some coffee code for PhotoSwipe init on click handler在点击处理程序上为 PhotoSwipe init 添加了一些咖啡代码
$ ->
$PhotoContainer = $('#MainPhoto')
$PhotoContainer.click ->
$pswpElement = document.querySelectorAll('.pswp')[0]
$items = []
$('.photo-item').each ->
$Img = $(@)
$items.push( { src: getUrlFromImg($Img).bigImgUrl, w: 1000, h: 1000 } )
$options = {
history: false,
focus: false,
index: 0
}
$gallery = new PhotoSwipe( $pswpElement, PhotoSwipeUI_Default, $items, $options)
$gallery.init()
When I click on #MainPhoto container event fired, $items array correctly fills by image urls and sizes and calls PhotoSwipe init() function, but nothing shows on screen当我点击#MainPhoto 容器事件触发时,$items 数组正确填充图像网址和大小并调用 PhotoSwipe init() 函数,但屏幕上没有显示任何内容
gem is improperly written should add gem 写错了应该添加
@import "photoswipe/index";
@import "photoswipe/photoswipe";
@import "photoswipe/default-skin/default-skin";
into application.scss进入application.scss
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.