2012-06-11 50 views
0

我從自定義標籤data-tooltip中加載工具提示文本。如果數據工具提示不存在,我希望隱藏工具提示。這可能嗎?如果你看一下使用qTip2隱藏如果空的內容

Custom functions that return no valid content will still cause the tooltip to be created! Replace these with an each() loop if this is not the desired behaviour. 

jsfiddle

回答

1

試試這個:

$(document).ready(function() { 
    $('#menu a').qtip({ 
     content: { 
      attr: "data-tooltip" 
     } 
    }); 
}); 

的qtip2文件說,這對於使用 「文本」,而不是 「ATTR」 「attr」,它說:

If no valid content is found within the elements attribute, and content.text is not defined, no tooltip will be rendered. 
+0

謝謝,這個工程很好,但在Chrome中產生警告:'qTip2:無法找到工具提示的內容!中止元素的工具提示:[Object object]' – olofom

+1

是的,這就是應該發生的事情。我只查看了qtip2的源代碼,並且在沒有要渲染的內容時(如它指出的),使用該消息進行簡單的log()調用。這只是一個警告,故意讓開發人員知道 - 沒有錯誤也沒有破壞代碼,這只是正常的! – Ian

+0

是的,我只是注意到自己,我甚至通過使用默認的標題屬性來獲得。謝謝! – olofom