0
我正在運行RefineryCMS 3.0.0並在主頁上添加了幻燈片顯示的nivo gem。RefineryCMS nivo滑塊無法使用require jquery
我已經將require行添加到了我的application.js頁面中;
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require nivo
//= require_tree .
這裏是我的主頁
<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>
目前這工作,但我必須與線再次包括jQuery庫;
<script src="/assets/jquery.js" type="text/javascript"></script>
如果我刪除此行幻燈片不起作用。有沒有更好的方法來做到這一點?
這沒有奏效,我仍然需要在腳本行之前加載jquery load – map7