2014-04-24 226 views
1

在堆棧溢出時搜索。我發現了一個我也面臨的老問題。但沒有人回答它。 所以只是想知道人有任何想法吧Tooltipster不能在ajax內容中工作

How to get jquery Tooltipster Plugin to work for newly created DOM elements?

以下是我的代碼

$(document).ready(function() { 
$('.test_link').tooltipster({ 
    interactive:true, 
    content: 'Loading...', 
    functionBefore: function(origin, continueTooltip) { 
     continueTooltip();  
     // next, we want to check if our data has already been cached 
     //if (origin.data('ajax') !== 'cached') { 
      $.ajax({ 
       type: 'POST', 
       url: 'example.php', 
       success: function(data) { 
        // update our tooltip content with our returned data and cache it 
        origin.tooltipster('content', $(data)).data('ajax', 'cached'); 
       } 
      }); 
     // } 
    } 
}); 

}); 

回答

2

我的問題就迎刃而解了。

只需在ajax內容中添加實例化腳本。 還設置了多個選項:真

$(document).ready(function() { 
$('.test_link').tooltipster({ 
    interactive:true, 
    multiple:true, 
    content: 'Loading...', 
    functionBefore: function(origin, continueTooltip) { 
     continueTooltip();  
     // next, we want to check if our data has already been cached 
     //if (origin.data('ajax') !== 'cached') { 
      $.ajax({ 
       type: 'POST', 
       url: 'example.php', 
       success: function(data) { 
        // update our tooltip content with our returned data and cache it 
        origin.tooltipster('content', $(data)).data('ajax', 'cached'); 
       } 
      }); 
     // } 
    } 
}); 

}); 

它在Firefox.But爲我工作在其他瀏覽器沒有測試