Saturday, May 11, 2024
53
rated 0 times [  56] [ 3]  / answers: 1 / hits: 16722  / 13 Years ago, sun, february 19, 2012, 12:00:00

I want to use the javascript provided in Tritter´s Bootstrap. I´ve checked that all the .js files are pointed out ok.



I want to test if it works ok, so after reading the docs, I understand that I have to call the appropiate javascript function?




Using bootstrap-tooltip.js
Trigger the tooltip via javascript: $('#example').tooltip(options)




How may I call that function? It seems that it´s not enough to put the proper html, I have to call the function aswell?



Thanks for your help!!


More From » twitter-bootstrap

 Answers
33

Give a HTML element the ID of example and appropriate attributes like this:



<p><a href=# rel=tooltip title=first tooltip id=example>hover over me</a>,/p>


In your <head> create a JavaScript <script> element, make sure jQuery is loaded and then, within the jQuery, add the tooltip to the element with the ID of example:



<script type=text/javascript>
window.onload = function()
{
if(!window.jQuery)
{
alert('jQuery not loaded');
}
else
{
$(document).ready(function(){
$('#example').tooltip({'placement':'top', 'trigger' : 'hover'});
});
}
}
</script>


This will setup a tooltip when you hover over the #example element. Change top to left, right or bottom to change where the tooltip is placed in relation to the element itself.






In case you might want to in the future, this is how you'd set up a popover also.


[#87354] Saturday, February 18, 2012, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
collinarnoldp

Total Points: 10
Total Questions: 122
Total Answers: 109

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
collinarnoldp questions
;