admin管理员组文章数量:1325675
I have this function setup
var $this = $(this);
if (msg == null) {
$this.tooltip('destroy');
}
else
{
$this.tooltip({'title': msg, 'placement': 'right', 'trigger': 'manual'});
$this.tooltip('show');
}
The tooltip shows up fine, the the destroy line throws an error data[option] is not a function
. If I change it to tooltip('hide')
the tooltip hides itself, I just can't get it to remove itself. Can anyone help me sort this out?
I have this function setup
var $this = $(this);
if (msg == null) {
$this.tooltip('destroy');
}
else
{
$this.tooltip({'title': msg, 'placement': 'right', 'trigger': 'manual'});
$this.tooltip('show');
}
The tooltip shows up fine, the the destroy line throws an error data[option] is not a function
. If I change it to tooltip('hide')
the tooltip hides itself, I just can't get it to remove itself. Can anyone help me sort this out?
3 Answers
Reset to default 3If you didn't make a typo check if you use the latest version of Bootstrap's javascript plugins.
tooltip.js contains:
// 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]()
})
}
In the case of .tooltip('destroy');
The line if (typeof option == 'string') data[option]()
gives the error you mention if Tooltip.prototype.destroy
not exists.
I fix it by loading jquery-ui.min.js after bootstrap.min.js
$this.tooltip('destroy'); //it use Bootsrap tooltip
Try call jQuery
$(this).$(jQuery).tooltip('destroy');
$.ui.tooltip()
or replace function
$.fn.tooltip = jQuery.ui.tooltip;
本文标签: javascriptBootstrap Tooltip dataoption is not a functionStack Overflow
版权声明:本文标题:javascript - Bootstrap Tooltip data[option] is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742153775a2423678.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论