我对常规工具提示进入了相同的问题。在iPhone上,点击身体(即其他地方)时,它们不会消失。
我的解决方案是,当你点击工具提示本身时,它就隐藏起来。恕我直言,这应该集成在bootstrap分发中,因为它很少有很大影响的代码。
当你有机会来引导人士透露,在文件中添加tooltip.js
this.tip().click($.proxy(this.hide, this))
如方法Tooltip.prototype.init的最后一行:
Tooltip.prototype.init = function (type, element, options) {
this.enabled = true
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
var triggers = this.options.trigger.split(' ')
for (var i = triggers.length; i--;) {
var trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
}
}
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
// Hide tooltip when clicking on it. Useful for mobile devices like iPhone where eventOut
// (see above) on $element is not triggered and you don't get rid of the tooltip anymore.
this.tip().click($.proxy(this.hide, this))
}
如果没有在手头上,你可以用下面的方法达到同样的效果:
$(function()
{
// Apply tooltips
var hasTooltip = $("[data-toggle='tooltip']").tooltip();
// Loop over all elements having a tooltip now.
hasTooltip.each(function()
{
// Get the tooltip itself, i.e. the Javascript object
var $tooltip = $(this).data('bs.tooltip');
// Hide tooltip when clicking on it
$tooltip.tip().click($.proxy($tooltip.hide, $tooltip))
}
);
});
对我来说,这样做对我们很好呃在iPhone上体验:点击元素查看工具提示。点击它消失的工具提示。
无法得到您的问题..tooltip或popover? becouse tooltip在鼠标离开时消失 –
使用工具提示。 http://twitter.github.com/bootstrap/javascript.html#tooltips - 我想要它,所以如果工具提示是可见的,另一个工具提示被点击;可见工具提示将隐藏。 – user1381806
你可以发布你的HTML吗? – ZimSystem