2015-09-08 41 views
1

所以這看起來很奇怪。在我的Rails 4應用程序中,有兩個彈出窗口,一個在菜單中,另一個在視圖的側邊欄中。bootstrap彈出工作在一個地方,但不是其他?

每個視圖都將頭部分(資產管道)和導航部分(第一個彈出框)加載到其中。

導航欄中的彈出窗口工作正常,但視圖側欄中的彈出窗口不起作用。

在控制檯中,我可以看到標題,管道的所有JS文件,並且我沒有得到(...).popover is not a function,這表明jQuery確實正在加載。

在我的application.js文件,我有

$('[data-toggle="popover"]').popover('placement', 'bottom');

這是我的理解,應立即初始化所有popovers。我也嘗試在腳本標籤內的視圖中包含該行。

在問題的酥料餅目前使用的引導提供的,而我試圖得到它的工作確切的代碼,並且被包裝在一個if/else語句:

<% if current_user.nil? %> 
      <button type="button" class="btn btn-lg btn-danger" data-toggle="popover" title="Popover title" data-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button> 
    <% else %> 
      <%= button_to "Contribute!", new_project_charge_path(:project_id => @project.id), method: :get, class: "btn btn-primary" %> 
    <% end %> 

我也試圖消除的if/else看看這是不是問題,但沒有什麼區別。你認爲這裏的問題是什麼?謝謝!

回答

0

試試這個...我認爲你沒有正確設置選項。

$('[data-toggle="popover"]').popover({placement : 'bottom'}); 
+0

好吧,我會死的!我已經把這個搜索到了死亡。我從來沒有猜到過,因爲它對第一個popover工作正常......非常感謝你! – HolyMoly

+0

@MalikBrahimi http://www.schmalz.io/contact/ – Schmalzy

相關問題