爲什麼選項卡在軌道中不能正常工作? Bootstrap的JavaScript文件沒有正確加載,或者我做錯了什麼?我有一個標籤面板,基本上有兩個內容。一個用於問題,另一個用於博客文章。無論何時刷新頁面,博客文章的內部HTML都會與問題面板混合在一起,就像Bootstap的腳本從未實際「加載」一樣。引導程序的怪異行爲
要來舉例說明我的問題,這裏是當我刷新頁面的圖像:
而這裏的,當我點擊其中一個選項卡的圖像。 (腳本加載,並且分離出的內容我想要的方式。)
問題的標籤:
博客文章的標籤:
應用。 js code:
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .
面板代碼:
<div class="well">
<ul class="nav nav-tabs">
<li role="presentation"><a class="none white" href="#questions" aria-controls="questions" role="tab" data-toggle="tab">Questions</a></li>
<li role="presentation"><a class="none white" href="#posts" aria-controls="posts" role="tab" data-toggle="tab">Blog posts</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="questions">
<br>
<% @user.questions.each do |question| %>
<%= link_to question.title, question_path(question), :class => "ques" %>
<p class="pull-right">
<%= question.user.username %>
</p>
<hr/>
<% end %>
</div>
<div role="tabpanel" class="tab-pane active" id="posts">
<br>
<p><a href="#" class="ques">test blog post 123 123</a></p>
<p><a href="#" class="ques">test blog post 123 123</a></p>
<p><a href="#" class="ques">test blog post 123 123</a></p>
<p><a href="#" class="ques">test blog post 123 123</a></p>
</div>
</div>
</div>
我會從擺脫'
'和'
'標記開始 - 用CSS代替。 – max
您是否檢查過日誌以查看Bootstrap是否正在加載?我們不可能在這裏檢查這個回答你的問題。 –