Materialize: Enable html in tooltip content

Created on 17 Jun 2015  路  11Comments  路  Source: Dogfalo/materialize

Hi,

I would really appreciate if you could add html content on tooltip, at least for
.
I use tooltips for forms online help and a one line tooltip is not enough.

My easy fix is to replace .text with .html on line 1195 and 1222 of materalize.js but that would be better to implement this optionnaly with something like :

data-enable-html="true"

Thanks,

Tooltip enhancement has-pr

Most helpful comment

As I don't want to modify the materialize JS file, I use this code

$(document).ready(function() {
    $('.tooltipped').each(function(index, element) {
        var span = $('#' + $(element).attr('data-tooltip-id') + '>span:first-child');
        span.before($(element).attr('data-tooltip'));
        span.remove();
    });
});

All 11 comments

would be great!, recently I needed to add a line break or an icon but got to resign and used plaintext :(

:+1:

:+1: this would be very helpful

We need this!

Jup waiting for this aswell

Hi, as said in #2064

You just have to change the line 59 into the tooltip.js file :

newTooltip.children('span').text(origin.attr('data-tooltip'));

As :

newTooltip.children('span').html(origin.attr('data-tooltip'));

And it should works.

Really need this. I have two issues, 1) i need html in tooltips and 2) if you have a lot of text in the tooltip, you need to be able to control its width.

:+1:

As I don't want to modify the materialize JS file, I use this code

$(document).ready(function() {
    $('.tooltipped').each(function(index, element) {
        var span = $('#' + $(element).attr('data-tooltip-id') + '>span:first-child');
        span.before($(element).attr('data-tooltip'));
        span.remove();
    });
});

set data-tooltip using jquery not woking:

javascript:
$('.tooltipped').tooltip({delay: 50,tooltip:"I am tooltip"});

html:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bradley-varol picture bradley-varol  路  3Comments

hartwork picture hartwork  路  3Comments

SoproniOli713 picture SoproniOli713  路  3Comments

ericlormul picture ericlormul  路  3Comments

heshamelmasry77 picture heshamelmasry77  路  3Comments