Tooltipster ajax无法显示断线

时间:2014-05-22 16:55:28

标签: jquery ajax tooltip

我正在使用tooltipster插件,它工作正常。

以下是我的代码。

$(this).tooltipster({
                        content: 'Loading...',
                        functionBefore: function(origin, continueTooltip) {

                            // we'll make this function asynchronous and allow the tooltip to go ahead and show the loading notification while fetching our data
                            continueTooltip();

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

以下测试是我在getDetails.php中的内容

echo "Product Quantity : 200 <br/>";
echo "IP Quantity : 100 ";

问题是我添加了断行,但是当它出现在工具提示中时,它不在下一行,而是在同一行上。

1 个答案:

答案 0 :(得分:2)

当您拨打contentAsHTML时,请尝试将选项true设置为tooltipster,如下所示:

$('.tooltip').tooltipster({
    content: 'Loading...',
    contentAsHTML: true,
    functionBefore: function(origin, continueTooltip) {

        // we'll make this function asynchronous...
        continueTooltip();

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

请确保您知道data的价值始终是格式良好且安全(已消毒)。