How to fix scrolling with twitter-bootstrap and popover?

前端 未结 5 641
余生分开走
余生分开走 2020-12-15 18:13

I am using twitter-bootstrap and popovers.

I am facing the following problem: when the user clicks on a link that opens a popover at the bottom of the page, it scr

5条回答
  •  醉话见心
    2020-12-15 18:40

    It seem like you now have to prevent the default behavior of the link because they added the option to popup the popover on hover/focus. Right now the link will activate and since the href is pointing to "#" it will bring you to the top of the page. Before in older versions, it used to prevent this default automatically.

    Your javascript code should look something like this:

     
    

    With html like this

    
         Click to toggle popover
     
    

    Here is a working JSfiddle. http://jsfiddle.net/hajpoj/KPU47/7/

    Edit: Alternatively you could use a div instead of a anchor tag and not have to do the whole prevent default thing.

    
    

提交回复
热议问题