Here is an example of how I "manually" add a HTML dependency to a datatable
. This works fine. When I try with attachDependencies
, the dependency is not attached.
library(DT)
library(htmltools)
dep <- htmlDependency(
name = "colResize",
version = "1.6.1",
src = normalizePath("colResize"),
script = "jquery.dataTables.colResize.js",
stylesheet = "jquery.dataTables.colResize.css",
all_files = FALSE
)
dat <- iris
datatable(
dat,
options = list(
colResize = list()
)
) %>% attachDependencies(dep, append = TRUE)
Why does this code not work?
I don't think it has anything to do with the way you're using it. The function
attachDependencies()
adds the object as an attribute, not as a dependency:However, without this function, you could still add your dependency in one line instead of three. I know that's not what you're looking for, but it's an option.
With my example: