I'm working on R Shiny App with some JS code, and i'm able to get it execute after a click, but I'm looking for it to load with the UI runs. I've modify the custom.js function to .on('load'.. vs .on('click. It did not change the behavior. Any suggestions how to get the js code to execute on ui load with the Shiny app?
# ui.R
library(shinyjs)
....
tags$script(src = "js/custom.js"),
downloadLink("downloadDataLink", "Download Data")
# custom.js
$( document ).ready(function() {
$(document).on('load','#downloadDataLink',function() {
Shiny.bindAll();
});
})
# server.R
output$downloadDataLink <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep="")
},
content = function(file) {
file.copy("./data/data.csv", file)
}
)