atomiks / tippyjs

Tooltip, popover, dropdown, and menu library
https://atomiks.github.io/tippyjs/
MIT License
12.03k stars 520 forks source link

How to destroy tippy? #849

Closed oshihirii closed 4 years ago

oshihirii commented 4 years ago

I currently apply tippy after initial content has loaded with:

tippy('[data-tippy-content]', { 
    followCursor: true,
    plugins: [followCursor]
});

When more content is dynamically added to the page, I want to ensure all content has tippy applied.

I have tried this approach of destroying tippy and re-applying it:

tippy('[data-tippy-content]').destroy();
tippy('[data-tippy-content]', { 
    followCursor: true,
    plugins: [followCursor]
});

But I get error:

Uncaught TypeError: Object(...)(...).destroy is not a function

I am referring to the following docs:

https://atomiks.github.io/tippyjs/v6/methods/#destroy

https://atomiks.github.io/tippyjs/v6/tippy-instance

Thank you.

atomiks commented 4 years ago

Since you're passing a string, an array of instances get returned, not an instance directly. So you'd need to use .forEach and destroy each one.