Skip to content

How to call custom javascript after the table is loaded? #38

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

Open
dhimmel opened this issue Dec 3, 2024 · 1 comment
Open

How to call custom javascript after the table is loaded? #38

dhimmel opened this issue Dec 3, 2024 · 1 comment

Comments

@dhimmel
Copy link

dhimmel commented Dec 3, 2024

I'd like to create header tooltips with tippy.js.

I've defined a python function like:

def _format_header(ci: reactable.HeaderCellInfo) -> htmltools.Tag | str:
    column_id = ci.name
    column_name = ci.value
    return htmltools.tags.span(column_name, data_tippy_content="My description")

This is creating an HTML span appropriate for tippy.js and if I run the following in the browser console after the table loads, I see my header tooltips:

tippy('[data-tippy-content]');

But how do we instruct the javascript to only run this tippy command after the table is loaded? Is there a convenience function for this?

I tried the following but it is still too eager:

window.addEventListener('DOMContentLoaded', function() {
  console.log('Loading header tooltips');
  tippy('[data-tippy-content]');
});
@dhimmel
Copy link
Author

dhimmel commented Dec 16, 2024

@machow any insights here?

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

1 participant