Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't Work on SVG elements #41

Closed
neuralism opened this issue May 9, 2017 · 12 comments
Closed

Doesn't Work on SVG elements #41

neuralism opened this issue May 9, 2017 · 12 comments

Comments

@neuralism
Copy link

I tried adding a title attribute to an SVG circle, but it doesn't work. Is this feature currently available?

@atomiks
Copy link
Owner

atomiks commented May 10, 2017

Can you use a div wrapper around it and put the title on that instead?

@neuralism
Copy link
Author

neuralism commented May 10, 2017

Thanks for your response! I wanted to try that, but I can't. I am using an SVG canvas and I have multiple SVG objects in that canvas populated using D3.

@atomiks
Copy link
Owner

atomiks commented May 10, 2017

Are you using a <title> tag like this?

<svg xmlns="http://www.w3.org/2000/svg">
  <rect x="20" y="30" width="200" height="150">
    <title>Hello, World!</title>
  </rect>
</svg>

This won't work currently as it only checks a title attribute on the element rather than a node like that. I can add it in as a feature for the next release though!

@neuralism
Copy link
Author

Nope! I am using it like:

<circle cx="68.572" cy="50" r="36.97051207883934" title="Hello, World!"></circle>

If this doesn't work then it's alright. I'll have to find my way around this. Thank you so much nonetheless! Tippy has been great so far!

@atomiks
Copy link
Owner

atomiks commented May 10, 2017

Are you passing in the svg element to be tooltipped or the circle node there?

If you pass it directly to the element with the actual title attribute, it will work: http://jsfiddle.net/819nouob/

@neuralism
Copy link
Author

Thank you so much! This is great! What if I have multiple SVG elements? Can I do a select all? you're a life-saver!

@atomiks
Copy link
Owner

atomiks commented May 10, 2017

In that case, pass just a CSS selector in: http://jsfiddle.net/819nouob/3/

If you have different types of elements, you can just separate them by commas like new Tippy('svg rect, svg circle')

@neuralism
Copy link
Author

Works! Thank you so much, atomiks! I have no idea how I can ever repay you! You saved my life!

@atomiks
Copy link
Owner

atomiks commented May 10, 2017

Awesome =]

@atomiks atomiks closed this as completed May 10, 2017
@nholden
Copy link

nholden commented Jan 1, 2018

Thanks for the great demo @atomiks! I'm new to Tippy.js and this was super helpful. In case anyone comes across this in the future, I updated the last demo to work with v2.0.8: http://jsfiddle.net/nholden/b7yk6mbb/1/

@atomiks
Copy link
Owner

atomiks commented Jan 2, 2018

Nice, thank you!

@GrahamLea
Copy link

Just adding a note here as Tippy no longer seems to read the title attribute by default (at least not on the SVG I'm working on), but this issue is highly ranked in Google when trying to get an SVG working with Tippy.

Instead of the above advice, you'll want to set your content into a data-tippy-content attribute instead of title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants