1

スタックオーバーフローを検索しているときに、私も直面している古い問題を見つけましたが、誰もそれに答えませんでした。だから、誰かがそれについて何か考えていることを知りたいだけです

新しく作成されたDOM要素に対してjquery Tooltipsterプラグインを機能させるにはどうすればよいですか?

以下は私のコードです

$(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');
                }
            });
      //  }
    }
});

});
4

2 に答える 2

3

私の問題は解決しました。

ajax コンテンツにもインスタンス化スクリプトを追加するだけです。オプション multiple:true も設定します

すなわち

$(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ではうまくいきましたが、他のブラウザではテストされていません

于 2014-04-24T09:37:44.470 に答える