>我有这个函数设置
var $this = $(this);
if (msg == null) {
$this.tooltip('destroy');
}
else
{
$this.tooltip({'title': msg, 'placement': 'right', 'trigger': 'manual'});
$this.tooltip('show');
}
工具提示显示正常,销毁行抛出错误data[option] is not a function
。如果我将其更改为tooltip('hide')
工具提示隐藏自己,我就无法让它自行删除。谁能帮我解决这个问题?
如果你没有打错字,请检查你是否使用最新版本的Bootstrap的javascript插件。
工具提示.js包含:
// TOOLTIP PLUGIN DEFINITION
// =========================
var old = $.fn.tooltip
$.fn.tooltip = function (option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
}
在.tooltip('destroy');
的情况下,如果Tooltip.prototype.destroy
不存在,则if (typeof option == 'string') data[option]()
行给出您提到的错误。
我通过在bootstrap.min之后加载jquery-ui.min.js来修复它.js
$this.tooltip('destroy'); //it use Bootsrap tooltip
尝试调用 jQuery
$(this).$(jQuery).tooltip('destroy');
$.ui.tooltip()
或替换功能
$.fn.tooltip = jQuery.ui.tooltip;