skip to Main Content

I want to make Twitter Bootstrap Popover that when document loaded, be open for ever. i see some solution but they show popover by click or hover!

There is my code:

$("#min-allowed-price .bar-label-shape").popover({
    offset: 10,
    trigger:'manual'
    });

3

Answers


  1. I want to make Twitter Bootstrap Popover that when document loaded

    $(document).ready(function() {
        $("button").popover("show");
    });
    

    be open for ever.

    Add disabled attribute to button or preventDefault() on hide.bs.popover event

    $('button').on('hide.bs.popover', function (e) {
      e.preventDefault();
    });
    

    jsfiddle

    Login or Signup to reply.
  2. You’re not actually triggering the popover. You can do that by calling popover('show'):

    $("#min-allowed-price .bar-label-shape").popover({
      offset: 10,
      trigger:'manual'
    }).popover('show');
    

    From Bootstrap’s Popover documentation:

    .popover('show')

    Reveals an element’s popover. Returns to the caller before the popover has actually been shown (i.e. before the shown.bs.popover event occurs). This is considered a "manual" triggering of the popover. Popovers whose both title and content are zero-length are never displayed.

    $('#element').popover('show')
    
    Login or Signup to reply.
  3. One way is to show popover manually and then remove the click event handler for the popover link.

    $('.popover-visible-trigger')
        .popover('show')
        .off('click');

    See the working jsfiddle.

    The thing, though, is that maybe you don’t need to do that. If you want the popover displayed at all times why not add it to markup?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search