-
Beta Was this translation helpful? Give feedback.
Answered by
boshek
Nov 6, 2023
Replies: 1 comment 7 replies
-
Ok if I change using ---
title: "Tooltips"
format: html
include-after-body:
- text: |
<script>
// Initialize the popovers for all elements with the "popover-trigger" class
var popoverTriggers = document.querySelectorAll(".popover-trigger");
popoverTriggers.forEach(function (popoverTrigger) {
new bootstrap.Popover(popoverTrigger);
});
// Add a single click event listener to the document to close any popover
document.addEventListener("click", function (event) {
popoverTriggers.forEach(function (popoverTrigger) {
if (!popoverTrigger.contains(event.target)) {
// Close the popover if the clicked element is not the trigger or popover content
var popover = bootstrap.Popover.getInstance(popoverTrigger);
if (popover) {
popover.hide();
}
}
});
});
</script>
---
```{r}
library(gt)
# Create a data frame
data <- data.frame(
Name = c("Alice"),
Details = c(
htmltools::HTML(
'<span class="popover-trigger" data-bs-toggle="popover" data-bs-title="Alice" data-bs-content="<a href=\'https://www.example.com\'>Visit Example.com</a>" data-bs-html="true">Click me</span>'
)
)
)
# Create the table
table <- data %>%
gt() %>%
gt::fmt(columns = c(Details), fns = function(x) x)
table
``` |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
boshek
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok if I change using
gt::fmt_markdown
togt::fmt(columns = everything(), fns = function(x) x)
this work for me. So the full qmd reprex is: