2015-10-06 52 views
2

我試圖引導旋轉木馬在我on Rails應用程序的紅寶石整合,所以我做了這樣的觀點:引導轉盤無法正常工作軌道

<head> 
</head> 
    <body> 
<div id="carousel" class="carousel slide" data-ride="carousel"> 
    <!-- Indicators --> 
    <ol class="carousel-indicators"> 
     <li data-target="#carousel" data-slide-to="0" class="active"></li> 
     <li data-target="#carousel" data-slide-to="1" ></li> 
     <!--<li data-target="#carousel-example-generic" data-slide-to="2"></li>--> 
    </ol> 

    <!-- Wrapper for slides --> 
    <div class="carousel-inner" role="listbox"> 
     <div class="item active"> 
     <img src="<%= image_url('lol.jpg')%>" alt="Leagues Of Legends"> 
     </div> 
     <div class="item"> 
     <img src="<%= image_url('SC2.jpg')%>" alt="Starcraft II"> 
     </div> 
    </div> 

    <!-- Controls --> 
    <a class="left carousel-control" href="#carousel" role="button" data-slide="prev"> 
     <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> 
     <span class="sr-only">Previous</span > 
    </a> 
    <a class="right carousel-control" href="#carousel" role="button" data-slide="next"> 
     <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> 
     <span class="sr-only">Next</span> 
    </a> 
    </div> 
    </body> 

它顯示一個旋轉木馬,我的第一個圖像和一切。

的問題是,沒有別的辦法:在上一個按鈕,下一個按鈕,甚至小點不執行任何操作上

點擊時,我不知道這是一個關係到我的代碼(懷疑以爲我測試了很多其他人,仍然是相同的)或軌道本身...

任何幫助,歡迎!

編輯

這是我的資產/ JavaScript的/ application.js中的文件:

//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
//= require bootstrap 
//= require bootstrap-sprockets 
//= require_tree . 
+0

你確定已經加載了所需的bootstrap JavaScript文件嗎? –

+0

@SaiqulHaq不知道你在說什麼,但我確實添加了導入「bootstrap-sprockets」並將「bootstrap」(用@)導入到我的aplication.css.sass中,我錯過了什麼? – Vroenguard

+0

編輯您的應用程序/ assets/javascripts/application.js文件 然後添加 // = require jquery // = require bootstrap-sprockets; 請先參閱文檔,https://github.com/twbs/bootstrap-sass –

回答

0

您需要執行JavaScript和jQuery代碼中的這個旋轉木馬的工作。

在HTML文件的末尾,添加這個(也可以是div和身體之間)

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> 
<script> 
    $(document).ready(function(){ 
    $('#mycarousel').carousel(); 
    }); 
</script> 

它應該做的伎倆。 您也可以將此代碼放在部分上並將其加載到您的應用程序佈局上。