更新到 bootstrap 2.3.0 后,我注意到弹出工具提示的奇怪行为。
如果您输入该字段并尝试离开,工具提示将消失并隐藏输入字段。此问题仅在最新版本的 bootstrap 中出现,不确定到底更改了什么,但 2.2.2 与 Prototype 配合良好。
jQuery.noConflict();
jQuery('input[data-content]').popover({
trigger: 'focus'
});
这是工作示例:http://jsfiddle.net/U6EDs/4/
最佳答案
此 github 问题 https://github.com/twitter/bootstrap/issues/6921描述你所看到的。我正在复制问题中的信息。
bootstrap-tooltip.js 中的这些行导致了问题:
, hide: function () {
var that = this
, $tip = this.tip()
, e = $.Event('hide') ///this line
this.$element.trigger(e) /// this line
if (e.isDefaultPrevented()) return //and this line
PrototypeJS 向 Element 原型(prototype)添加了方法,因此当 jQuery 尝试触发元素上的 hide()
方法时,它实际上触发了 PrototypeJS hide()
方法,该方法相当于 jQuery hide()
方法,将元素的样式设置为 display:none;
你有几个选择
- 删除js文件中上面标记的行
- 将事件重命名为其他名称(而不是隐藏)
- 使用 BootStrap 的 PrototypeJS 分支(当前适用于 2.3.2)
http://github.com/jwestbrook/bootstrap-prototype
*****免责声明***
我是目前正在将 BootStrap JS 组件移植到 PrototypeJS 的开发人员
关于jquery - 如果与 Prototype JS 一起使用,Popover 会隐藏父元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15087129/