Since 2.3 tooltips and popovers are broken when Prototype.js is included.
The problem is that the parent is hidden when the tooltip is hidden.
bootstrap-tooltip.js:
, hide: function () {
var that = this
, $tip = this.tip()
, e = $.Event('hide')
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
....
The line this.$element.trigger(e) causes problems, causes the parent element (the button, link or text) to be hidden. When I remove prototype.js everything works as expected. When I remove the this.$element.trigger(e) code, everything works as expected.
jQuery 1.9 (with noConflict of course) and prototype 1.7, any suggestions how to fix this?
I have the same problem on a Magento installation (which uses Prototype) with a Bootstrap theme. Also with noConflict mode. The only fix I could find was to comment the line out.
Third-party libraries are technically not officially supported. Would still be nice to know the cause of such weirdness of course.
PrototypeJS adds methods to the Element prototype so when jQuery tries to trigger the hide() method on an element it is actually firing the PrototypeJS hide() method, which is equivalent to the jQuery hide() method and sets the style of the element to display:none;
solutions to this
- remove the line of code like you did
- use a different event name for that event
- use the Prototype version of Bootstrap that I've created, linked below
I've not completed all of the Javascript Modules but I've done what I think are the most popular, Tooltips and Popovers are done.
http://github.com/jwestbrook/bootstrap-prototype
I have found that popovers are broken in 2.3 and I do not include prototype. Reverting to 2.2.2 with no other change makes them work again.
I got used to the fact that popovers get more and more broken on every release. But this time regular 2 hours of debugging do not help. "data-popover-data" gets cleaned up in random manner, or popovers disappear or get trimmed within "collapse". Have to revert to 2.2.2 as well.
@rivets: how, specifically, are they broken for you?
Please stop polluting this issue, this issue is about the tooltips/popovers + prototype not working, not about some misconfiguration or running an old jQuery version.
I have a same issue with bootstrap and Magento, but my ticket was closed, with help of paales I was able to fix it by renaming hide() method to hideTooltip().
@captainpete I'm willing to bet this pull request will be closed given the outcome of #5318. The way we addressed was in addition to calling the plugin on an element(s) to also drop the hide() definition, e.g. element.hide = undefined. jQuery.noop() is another option.
Thanks @dgsmith2. That fills in the gaps somewhat. As mentioned on #7130, there's a few open pull-requests overloading the same events from different modules, seems namespacing the events is close-at-hand.
Experiencing the same problem with Wordpress.
in 3.0 we've changed the event name (by namespacing events) – this should solve your guy's problem - cheers
3.0 uses namespace
var e = $.Event('hide.bs.' + this.type)
That won't solve this issue with Prototype since jQuery will call the canonical event name 'hide' which will still conflict with the Prototype hide() method on the element.
The event name itself needs to change, eg, 'bs:hide.' + this.type (to use Backbone-inspired namespacing).
@fat why you don't use namespace like moos suggested (Backbone Namespacing)?
event namespacing did not fix this issue using bootstrap 3.0.0 and prototype 1.7
There's supposedly still some .trigger() vs .triggerHandler() problem, and nobody has submitted a patch against v3 for it.
I found that after you call your bootstrap .tooltip() function on your element, you can simply add an action (when the tooltip is hidden) that removes the "display:hidden" style on your element (that has been imposed by Prototype).
By doing this, you are not removing anything from either the bootstrap or prototype libraries. You should be forward compatible with future libraries (if you update either one in the future).
Example:
<span class='tooltipped' title='This is my tooltip text'>Hover to see my tooltip</span>
jQuery(document).ready(function() {
jQuery(".tooltipped").tooltip();
jQuery(".tooltipped").on("hidden.bs.tooltip",
function() {
jQuery(this).css("display", "");
});
});