Can't understand why PhotoSwipe doesn't show anything when I'm trying to add it into Rails project
- Used this gem: https://github.com/skakri/photoswipe-rails
- Step by step reproduced manual: https://photoswipe.com/documentation/getting-started.html#init-add-pswp-to-dom
- Wrote 'click' handler But it shows nothing
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
Added some coffee code for PhotoSwipe init on click handler
$ ->
$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
gem is improperly written should add
into application.scss