Mini John
Mini John

Reputation: 7941

Add Image into Tooltip in Ruby on Rails

I'm trying to include an image in my Tooltip:

My Link:

<%= link_to "#", class: "tag-tooltip",
                    'data-placement' => 'right',
                    :rel => "tooltip" %>

My Js(coffee):

$(document).on "ready page:change", ->
  $(document).ready ->
  $(".tag-tooltip").tooltip({ title: "whatsup", content: "<img src=\"http://icdn.pro/images/fr/a/v/avatar-barbe-brun-homme-utilisateur-icone-9665-128.png\" />", html: true})

But only the Text is appearing.. What am i Missing ?

Upvotes: 0

Views: 724

Answers (1)

vee
vee

Reputation: 38645

Use template in place of content like follows:

$(document).on "ready page:change", ->
  $(document).ready ->
    $(".tag-tooltip").tooltip({ title: "whatsup", template: "<img src=\"http://icdn.pro/images/fr/a/v/avatar-barbe-brun-homme-utilisateur-icone-9665-128.png\" />", html: true})

Update:

Based on the gem code, it appears that the content of the tooltip is actually the title. So you could also do:

$(document).on "ready page:change", ->
  $(document).ready ->
    $(".tag-tooltip").tooltip({ title: "<img src=\"http://icdn.pro/images/fr/a/v/avatar-barbe-brun-homme-utilisateur-icone-9665-128.png\" />", html: true})

Upvotes: 2

Related Questions