Damir Nurgaliev Damir Nurgaliev - 8 days ago 7
Ruby Question

How to add image to foundation tooltip

i'm using foundation tooltips to show the users which liked the post. For example here i need to show current user avatar:

span.has-tip data-tooltip="" title="#{image_tag(current_user.avatar)}"Like


But when I reload page i get an tooltip with:

<img src=


and nothing else.
How should I correctly use images in tooltip?

If I call image_tag(current_user.avatar) in other place it works fine.

Answer

In Foundation 6.2.4 you would need to specify a custom template using the data-template attribute (see available options at http://foundation.zurb.com/sites/docs/tooltip.html#js-options).

This would look something like

   span.has-tip data-tooltip="" data-template="<div class='tooltip'>#{image_tag(current_user.avatar)}}</div>"Like

Coming in version 6.3 (due to be released 2 weeks from Thursday) there will be an option to allow HTML content in your tooltip directly.