6

I have a shiny app that has a print screen button, but after updating the shinyjs package, the code no longer works.

I got this solution from RShiny print current page and it used to work, but not any more.

Here's the code:

library(shiny)
library(shinyjs)
library(V8)

jsCode <- 'shinyjs.winprint = function(){
window.print();
}'

ui <- shinyUI(fluidPage(
  useShinyjs(),
  extendShinyjs(text = jsCode),
  actionButton("print", "PRINT")
))



server <- shinyServer(function(input, output) {
  
  observeEvent(input$print, {
    js$winprint()
  })
})


shinyApp(ui, server)

But I get the below error now and the app won't deploy anymore.

Error: shinyjs: extendShinyjs: `functions` argument must be provided
SportSci
  • 227
  • 3
  • 9

1 Answers1

11

Please try

extendShinyjs(text = jsCode, functions = c("winprint")),

instead of

extendShinyjs(text = jsCode),

in your ui.

YBS
  • 19,324
  • 2
  • 9
  • 27