Twitter Bootstrap Popovers not working for Dynamically Generated Content

后端 未结 3 517
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 07:45

New to posting on stackoverflow here, so my apologies in advance if I messed anything up here.

I\'m using Twitter Bootstrap\'s popovers. My popovers seem to be worki

相关标签:
3条回答
  • 2020-12-03 07:53

    This Function will work properly in the selector you have to specify the location on the page where you have to search "rel=popover" like I put *

    $(function ()  
    {
    console.info($("*[rel=popover]"));
    $("*[rel=popover]").popover();
    });
    
    0 讨论(0)
  • 2020-12-03 08:11

    In the success function of the ajax you need to call the popover. Something like this

    success:function(){
      $("[rel=popover]").popover({placement:'left'});
    }
    
    0 讨论(0)
  • 2020-12-03 08:18

    You need to call $("[rel=popover]").popover({placement:'left'}); AFTER the elements are in the DOM.

    UPDATE

    If you are using jQuery

    $(element_selector)
      // load results into HTML of element_selector
      .load('your/php/file')
      // when done, initialize popovers
      .done(function(){
        $("[rel=popover]").popover({placement:'left'});
      });
    

    OR a catch all for jQuery ajax requests

    $.ajaxComplete(function(){
        $("[rel=popover]").popover({placement:'left'});
      });
    
    0 讨论(0)
提交回复
热议问题