Why javascript won't work in Twitter's Bootstrap even when calling the function and the js file?

StackOverflow https://stackoverflow.com/questions/9354026

  •  28-10-2019
  •  | 
  •  

Question

I can't get javascript to work with Twitter's Bootstrap.

I've got this

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

And I want it to appear as a tooltip.

It won't work, so I added this inside the HEAD:

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

Noting thta it still wasn't working, I've deleted all script reference inside the page and added only this inseide the HEAD:

<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js"></script>

I´m not calling any particular file that I've downloadad, but hotlinking the original ones, and still the tooltip won't appear.

Note: I´m trying to set a new Drupal theme, so my site is inside Drupal (and the page is a tpl.php file).

Thanks for your insight!!

Was it helpful?

Solution

If you're wanting to use github files directly you need to use the raw, so you should point at https://raw.github.com/twitter/bootstrap/master/js/bootstrap-tooltip.js not https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top