Tippyjs: Enable tippy for new dynamically added elements

Created on 15 May 2018  路  4Comments  路  Source: atomiks/tippyjs

Is there any way to automatically enable tippy for elements which are added dynamically (via ajax) in page?

For example, if i activate tippy:

<script>
tippy('.btn')
</script>

then it's all ok. But if new elements with the same class .btn are added to the page dynamically, they won't have the tippy.
A lot of stuff is loaded via ajax, so manually activating the tippy after each ajax request will be a bad practice (time consuming, forget somewhere to call it, etc.)

Most helpful comment

This is nice use case for event delegation.

Apply the tippy to the parent container of your .btn elements, and use target

tippy(parent, { target: '.btn' })

All 4 comments

This is nice use case for event delegation.

Apply the tippy to the parent container of your .btn elements, and use target

tippy(parent, { target: '.btn' })

Damn and I've RTFM, but skipped the delegation part :/

Thanks!

@atomiks
Still working? I can not see target param in docs.

Use tippy.delegate() instead now, but otherwise the same.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kearsan picture Kearsan  路  3Comments

mreinstein picture mreinstein  路  5Comments

gclark18 picture gclark18  路  4Comments

faroukcharkas picture faroukcharkas  路  4Comments

patrickhlauke picture patrickhlauke  路  3Comments