seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.49k stars 997 forks source link

Tooltips do not work when a link's "rel" attribute contains multiple values #609

Closed lukehorvat closed 10 years ago

lukehorvat commented 11 years ago

In a Rails 3.2 app, if I do this:

<%= link_to "Link", "#", method: "put", rel: "tooltip", title: "A tooltip." %>

It outputs this:

<a href="#" data-method="put" rel="tooltip nofollow" title="" data-original-title="A tooltip.">Link</a>

As can be seen, specifying a data-method results in a "nofollow" value being appended to the rel attribute, which already has the value "tooltip". This causes no Bootstrap tooltip to be created for the link element, because the jQuery selector in bootstrap.js only checks whether rel is exactly equal to "tooltip", like so:

$("a[rel=tooltip]").tooltip()

So I think it would be better if we made it check whether the rel attribute merely contains the value "tooltip", using jQuery's attribute contains word selector. Example:

$("a[rel~=tooltip]").tooltip()

Objections?

lukehorvat commented 11 years ago

Hmmm, I also noticed something with the following line in bootstrap.js:

$(".tooltip").tooltip()

Am I wrong in assuming that this is simply meant to initialise a Bootstrap tooltip for any element on the page with class .tooltip? If so, I suggest renaming it to something else, like .has-tooltip. Why? Because the .tooltip CSS class is already used by Bootstrap and has certain style properties like opacity: 0 which effectively renders your elements invisible, so we should use naming that does not conflict with it.

Same deal for popovers as well.