wintercounter / Protip

A new generation jQuery Tooltip plugin
http://protip.rocks
MIT License
359 stars 38 forks source link

Make selector's text as default title #16

Closed pappfer closed 8 years ago

pappfer commented 8 years ago

I think it makes sense to have the selector's text as the default one for the tooltip. Bootstrap does this, too.

Also, what does $(this) refer to? I tried to make the element's text the default title (see code below), but this solution didn't work.

$.protip({
    selector: '.jstree-anchor',
    defaults: {
        title: $(this).text()
    }
});
wintercounter commented 8 years ago

There is no closure, this will refer your own scope. I understand what you want to achieve but I don't know what would be the use case for this. Can you explain why you want the tooltip have the same content as the element you have the tooltip on?

pappfer commented 8 years ago

For example when the text won't fit the container. See screenshot. protip

wintercounter commented 8 years ago

Looks reasonable. I'll do it later this day or tomorrow. Also please note that I'm going to use innerHTML instead of textContent.

BTW: Udv :)

wintercounter commented 8 years ago

It's done. It took faster than i tought :) Now you may use the :this operator in the title attribute.

$.protip({
    selector: '.jstree-anchor',
    defaults: {
        title: ':this'
    }
});