I am calling a custom js file using the extendShinyjs
. function. The following is the snippet of the app and it works perfectly on the windows desktop. I wrapped the app in a docker image and as I launch the app to test using the command below
`sudo docker run -p 9000:9000 example_app R -e 'shiny::runApp("app.R")'
All the packages load and I get
`here starts /`
and shinyjs: error cannot find "//www/custom_script.js" file.
````r
library(shiny)
library(shinyjs)
library(here)
shiny::shinyApp(
ui = shiny::fluidPage(
shinyjs::useShinyjs(),
tags$head(
shinyjs::extendShinyjs(script = here::here("www", "custom_script.js")),
),
shiny::selectInput(
"region", "Region: ",
c("The Americas", "Europe", "Middle East")
),
), server = function(input, output, session) {
shiny::observeEvent(input$region, {
js$filterSingleValue("Region", input$region)
})
}
)
Is it something related to the way I am calling or docker requires some additional input ? I am using rocker/shiny image with libv8 installed
Hmm that's definitely a bug. And I think I have a good idea of why that's happening. When I check for the file I'm only looking at the absolute path, and not taking into account the resourch paths (that are added with addResourcePath()
).
That being said, I don't recommend using here::here
for shiny resources, that function is great for interactive scripts, but for shiny I'd suggest being more explicit about where files live
Hi,
writing in this issue since it seems to be related: I am also using a docker container to deploy a shiny app (see my MetaShARK* repos if interested in details) and some {shinjs} features such as onclick()
do not work. My dev and deploy environments are slightly different (Ubuntu 19.04 in dev and 18.04 on server).
If you're able to provide a full reproducible example, it would make it easier for me to test/debug
I won't have time soon to work on such a reprex BUT as I think this could help you, I will try as soon as possible. I think it will be a dockerized app ready to deploy. Anyway, thanks for replying :)
Don't worry, this sounds like a complex issue so I don't know when I'll find the time to look into it too :)
@gadepallivs and @earnaud : the latest version of shinyjs (not yet on CRAN, but on github) should hopefully fix this. I had to make a BREAKING CHANGE to support this, but this was a change that had to be done. Now the javascript files are being loaded the same way that any other web resource in shiny is loaded.
Most helpful comment
@gadepallivs and @earnaud : the latest version of shinyjs (not yet on CRAN, but on github) should hopefully fix this. I had to make a BREAKING CHANGE to support this, but this was a change that had to be done. Now the javascript files are being loaded the same way that any other web resource in shiny is loaded.