2013-07-06 64 views
7

這裏是我的HTML:Twitter的引導Popovers不工作

<div id="disclaimer">After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div> 

的JavaScript:

$('#disclaimer').popover({ 
    trigger: 'hover', 
    html: true, 
    placement: 'right', 
    content: 'hello world' 
}); 

當我將鼠標懸停在元素,沒有任何反應..沒有JavaScript錯誤什麼的,不知道什麼是錯

回答

9

使用你的確切代碼,我所要做的所有工作就是將它包裝在函數調用中,並將腳本放在div標籤下面。如果你把你的jQuery放在一個onload函數中,它也可以工作。祝你好運。

使用此:

<div id="disclaimer" >After 30 Days you'll have the option to keep your account for $15 per month -no contract required-or revert to a single page free account.*</div> 

<script> 
$(function() 
{ 
    $('#disclaimer').popover(
    { 
    trigger: 'hover', 
    html: true, 
    placement: 'right', 
    content: 'hello world' 
    }); 
}); 
</script> 

OR

$(document).ready(function() 
{ 
    $('#disclaimer').popover(
    { 
    trigger: 'hover', 
    html: true, 
    placement: 'right', 
    content: 'hello world' 
    }); 
}); 
+1

我把我的包裝在一個'$(document).ready'中,仍然沒有任何反應:( – dennismonsewicz

+0

你可以把它放到腳本標籤的html中嗎?如果仍然不起作用,你可能想檢查確保你的工具提示包含在你的[bootstrap.js](http://twitter.github.io/bootstrap/javascript.html#tooltips) – Jonathan

+0

我明白了......這是ActiveAdmin JavaScript與twitter bootstrap衝突...感謝您的幫助! – dennismonsewicz

1

我已經過了一天找,爲什麼我的酥料餅不工作後得到自動禁用由於事件發生在我的網頁(一個複雜的應用程序,取決於正在進行的狀態而被啓用/禁用的東西),關鍵是沒有它準備好文檔,但是將它放在一個函數中,因爲它在文檔初始化後在按鈕上單擊。

+0

似乎你無法克隆彈出窗口,這是我的問題。謝謝,這個提示讓我嘗試了一種不同的方式H。如果我在克隆後應用popover,它會起作用。 – Nick