2013-08-28 84 views
0

在我的代碼中,我設置了我的表的HTML內容,並且我希望在將鼠標懸停在table的每個單元格上時顯示彈出窗口。我正在使用bootstrap。添加bootstrap popover不起作用

在javascript:

html = html + "<td>"+data[i]["initial_score"]+"</td>"; 
     html = html + "<td onmouseover=\"showpopover('"+main_image_data['score_reason']+"')\">"+main_image_data['bonus']+"</td>"; 
     html = html + "<td>"+variant_data['bonus']+"</td>"; 

showpopover功能:

showpopover=function(message){ 
    $(this).popover({ placement: "bottom",title:"Score",content:"<div>THIS IS SCORE</div>"}); 
}; 

但是,當我將鼠標懸停在該單元格,它不表現出任何酥料餅。 我在showpopover函數中錯誤地使用了'this'嗎?

回答

0

這裏是工作Fiddle希望它可以幫助你!

$popover = $(val).popover({ 
    trigger: "hover", 
    placement: "bottom", 
    title:"Score", 
    content:"<div>THIS IS SCORE</div>" 
}); 
+0

由於內容爲html,請務必將{html:true}添加到彈出窗口的選項中。 – mccainz