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!
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.
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.
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.
You can solve that by preventing the default action of the anchor element:
$('a#testpop').on('click', function(e) {e.preventDefault(); return true;});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With