'Slideshow images load on page reload Rails & OwlSlideshow
I'm facing the following problem: I'm using an external API that returns a image hash that has multiple images. When I enter the show page for the element that has such images, I loop through them and use OwlSlideshow to display them. The thing is that when I first enter the show page the images doesn't load, but when I reload the page, they do. Here's the code:
controller
def show
request = HTTParty.get(BASE_URL + "properties/#{params[:id]}", :headers => HEADERS)
@response = JSON.parse(request.body)
end
view
<div class="images">
<%if @response["property_images"]%>
<div class="owl-carousel">
<% @response["property_images"].each do |image| %>
<div class="item">
<%=image_tag image["url"]%>
</div>
<% end %>
</div>
<%else%>
<p>No property images</p>
<%end%>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|