2011-10-10 21 views
0

我無法找到完整的文檔。例如,popover效果(here)將使用DOM的data-origin-title屬性作爲自己的標題,並data-cotent其內容:你如何知道如何使用twitter-bootstrap?

$('#somedom').hover (-> 
    $(this).addClass("hover") 
    $(this).attr("data-original-title","Location") 
    $(this).attr("data-content":'The popover plugin provides a simple interface for adding popovers to your appli cation. It extends the bootstrap-twipsy.js plugin, 
       so be sure to grab that file as well when including popovers in your project!') 
    $(this).popover({}) 
    $(this).popover("show") 
    ),-> 
     $(this).removeClass("hover") 

在哪裏學的?官方文件沒有data-origin-title屬性。在源代碼bootstrap-popover.js中都沒有。

回答

3

所有你需要的是在選項表中。它爲標題抓取title屬性,爲內容抓取data-content(第3列)。您在HTML上看到的data-original-title在執行後由插件腳本添加,忽略它。

這樣做的想法是,你已經對HTML的信息:

<div id="mything" title="My title=" data-content="Some text here">Test popover</div> 

所以,你的腳本只有這樣做,你不需要來處理事件:

$('#mything').popover()