Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clicking a popover scrolls back to top of the page [Bootstrap and Django]

I am using bootstrap with Django and so far everything as worked. However, I am trying to use the popover functionality, and I keep running into a problem. Whenever a click my popover, the page scrolls back to the top... BUT the popover do appear. here is my code:

//////////<..... a lot more HTML ....>////////// <div class="bs-docs-example"> <a href="#" class="btn btn-large btn-danger" rel="popover" title="A Title" id="testpop" data-content="And here's some amazing content. It's very engaging. right?">Click to toggle popover</a> </div> {% endblock %}   {% block js %} {{ block.super }}  {% bootstrap_javascript_tag "modal" %} {% bootstrap_javascript_tag "alert" %} {% bootstrap_javascript_tag "tooltip" %} {% bootstrap_javascript_tag "popover" %}  <script type="text/javascript"> $("#testpop").popover(); </script> 

Thanks a lot!

like image 767
abisson Avatar asked Sep 25 '12 20:09

abisson


People also ask

How do you use bootstrap Popovers?

To create a popover, add the data-toggle="popover" attribute to an element. Note: Popovers must be initialized with jQuery: select the specified element and call the popover() method.

How does bootstrap define popover?

A Bootstrap Popover is an attribute in bootstrap that can be used to make any website look more dynamic. Popovers are generally used to display additional information about any element and are displayed with a click of a mouse pointer over that element.

What is Popper bootstrap 5?

When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.


1 Answers

You can solve that by preventing the default action of the anchor element:

$('a#testpop').on('click', function(e) {e.preventDefault(); return true;}); 
like image 192
dokkaebi Avatar answered Oct 07 '22 19:10

dokkaebi