2013-10-19 125 views
0

我有以下的HTML和CoffeeScript的一個Rails應用程序:引導酥料餅的破壞內容

<span id="CEO_portrait"><%= image_tag "CEO_portrait.png", class: "portrait" %></span> 
<div id="tooltip_container"> 
    <div id="CEO_biography"> 
    "The CEO founded the company in 1969." 
    </div> 
</div> 

$ -> 
    $('#CEO_portrait').popover 
    title: "James E. Lee" 
    placement: "top" 
    trigger: "hover" 
    html: true 
    container: "#tooltip_container" 
    content: -> 
     $('#CEO_biography') 

的酥料餅的出現與相應的內容第一次我的鼠標懸停在「#CEO_portrait」跨度然而,當。我的鼠標離開跨度,ID爲「CEO_biography」的div被刪除,結果,當我將鼠標再次懸停在'#CEO_portrait'上時,標題顯示出來,但沒有顯示內容,我不明白爲什麼這是我怎樣才能讓內容持續存在?

回答

0

http://bootply.com/88701

<span id="CEO_portrait">test</span> 
    <div id="tooltip_container"> 
    <div id="CEO_biography"> 
    "The CEO founded the company in 1969." 
    </div> 
</div> 

在這裏爲我的作品在引導3和引導2.3.2

是內容消失,但下一次我將內容懸停仍然在酥料餅。看看的例子..

請確保您有所有加載等的引導腳本/ CSS的..

+0

@ user1380016如果回答您的問題,請將此答案標記爲已接受,否則請提供有關未解決問題的反饋。謝謝 – Trevor

0

保存內容的情況之外:

$ -> 
myContent = $('#CEO_biography') // save the content for future use 

$('#CEO_portrait').popover 
title: "James E. Lee" 
placement: "top" 
trigger: "hover" 
html: true 
// container: "#tooltip_container" // I don't know why you use this 
content: -> 
    myContent 

這是我的工作使用數據溶液屬性:

$("[data-toggle='popover-div']").each -> 
that = $(this) 
content = $(that.data("content-div")) // Save content of the id given in "data-content-div" 

that.popover 
    html: true 
    content: -> 
    content 

a.btn.btn-share(data-toggle="popover-div", data-content-div="#share-popover", 
data-trigger="click", data-placement="top") 
    | Share <i class="fa fa-share"></i> 

.share-popover-wrapper // Display: none 
    #share-popover 
    // [... Content goes here ...]