Change Twitter Bootstrap Tooltip content on click

前端 未结 25 1234
情深已故
情深已故 2020-11-27 10:02

I have a tooltip on an anchor element, that sends an AJAX request on click. This element has a tooltip (from Twitter Bootstrap). I want the tooltip content to change when th

25条回答
  •  情深已故
    2020-11-27 10:39

    For BS4 (and BS3 with minor changes) .. after hours of searching and trials, i came up with the most reliable solution for this problem and it even solves the problem of opening more than one (tooltip or popover) at the same time, and the problem of opening automatically after losing focus, etc.

    $('[data-toggle="tooltip"]').tooltip({
      trigger: 'hover'
    }).on('shown.bs.tooltip', function() {
      var link = $(this);
      var data = '';
      data += '
      '; data += '
    • Sherif Salah
    • '; data += '
    • Muhammad Salah
    • '; data += '
    • and a gazillion more...
    • '; data += '
    '; link.attr('data-original-title', data); setTimeout(function() { if (link.is(':hover')) { link.tooltip("dispose").tooltip("show"); } }, 1000); });
    
    
    
    
      
      
      
    
    
    
      
      
      
      
    
    
    

提交回复
热议问题