Reputation: 5126
I'm running RefineryCMS 3.0.0 and have added the nivo gem for a slideshow on the home page.
I've added the require line to my application.js page like so;
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require nivo
//= require_tree .
Here is my home page
<body>
<div class="logo_white">
<%= image_tag("logo-white.png", class:"logo-white") %>
</div>
<% main_slideshow = Refinery::ImageSlideshows::ImageSlideshow.includes(:image_slides).find_by_title('frontpage') %>
<div id="wrapper">
<% if main_slideshow %>
<div class="slider-wrapper">
<div id="slider">
<% main_slideshow.image_slides.each do |image_slide| %>
<%= link_to image_slide.link_url do %>
<%= image_tag image_slide.image.url, :alt => image_slide.title, :title => image_slide.caption %>
<% end %>
<% end %>
</div>
</div>
<% else %>
Please create the 'frontpage' slideshow in the admin section
<% end %>
</div>
<script src="/assets/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
var ready;
ready = function(){
$('#slider').nivoSlider({
<%= raw main_slideshow.js_config if main_slideshow %>
});
};
$(document).ready(ready);
$(document).on('page:load', ready);
</script>
</body>
This currently works but I have to include the jquery library again with the line;
<script src="/assets/jquery.js" type="text/javascript"></script>
If I remove this line the slideshow doesn't work. Is there a better way of doing this?
Upvotes: 0
Views: 72
Reputation: 4819
Maybe jquery included in refinery does not support $(something), instead try jQuery(something).
Upvotes: 0