Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Reference HTML elements in a data-tippy attribute #1178

Open
pontus-mp opened this issue Aug 21, 2024 · 0 comments
Open

Reference HTML elements in a data-tippy attribute #1178

pontus-mp opened this issue Aug 21, 2024 · 0 comments

Comments

@pontus-mp
Copy link

Problem

Basic scenario, you are using the delegate plugin to automatically initialize a bunch of tippy.js tooltips:

delegate("body", {
  target: ".tippy",
});

This makes it really easy to add tons of tooltips, configurable almost entirely through HTML attributes:

<button class="tippy" data-tippy-trigger="click" data-tippy-content="This is a click-triggered tooltip!">Test/<button>

However, the following doesn't seem to be replicatable using the previous approach:

tippy(targets, {
  content: document.getElementById('hidden-tooltip-content-element'),
});

Solution

Add support for a new data-attribute that contains a selector:

<button class="tippy" data-tippy-content-selector="#hidden-tooltip-content-element">Test/<button>

This should not affect backward-compatibility, as long as people haven't been intruding on the data-tippy- namespace.

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

No branches or pull requests

1 participant