1

I can't seem to manage to get the action button in shiny working. Nothing happens when i press "click me" and there is no error message.

Does anyone have a clue what might be wrong?

    library(shiny)

ui <- fluidPage(
  tags$head(tags$script(src = "message-handler.js")),
  actionButton("do", "Click Me")
)

server <- function(input, output, session) {
  observeEvent(input$do, {
    session$sendCustomMessage(type = 'testmessage',
                              message = 'Thank you for clicking')
  })
}

shinyApp(ui, server)

here is my session info:

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale:
[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252    LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C                    LC_TIME=Swedish_Sweden.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.4.0.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.6        packrat_0.5.0     digest_0.6.27     later_1.1.0.1     mime_0.9          R6_2.5.0          xtable_1.8-4      jsonlite_1.7.2    magrittr_2.0.1   
[10] rlang_0.4.10      promises_1.1.0    tools_3.6.3       httpuv_1.5.2      rsconnect_0.8.16  fastmap_1.0.1     compiler_3.6.3    htmltools_0.5.1.1
chilifan
  • 157
  • 1
  • 12
  • Please include **message-handler.js**. – Stéphane Laurent Sep 09 '21 at 09:51
  • This is an [XY problem](https://en.wikipedia.org/wiki/XY_problem). Replace the call to `sendCustomMessage()` with `print("hi")` and `Hi` appears in the console when the button is clicked. So the problem is not due to any lack of response on the part of the `actionButton`. – Limey Sep 09 '21 at 10:46
  • [This](https://shiny.rstudio.com/articles/js-send-message.html) is relevant. – Limey Sep 09 '21 at 10:47
  • tnx guys. I created a bad example here I see. I have the same issue on another piece of code not using the sendCustomMessage(), but I'm not sure how to recreate the issue in to a reprex. I thought this example would do the trick but apparently not! ;) sorry for taking up your time!:) – chilifan Sep 09 '21 at 11:23

0 Answers0