Page refresh Button in R shiny

后端 未结 1 705
轻奢々
轻奢々 2020-12-10 19:37

I tried to implement a page refresh button following the link here. However when I tried deploying to shinyapp.io, it failed and asked for installing package

相关标签:
1条回答
  • 2020-12-10 20:09

    Just to be complete, the code below is a minimal example of a working Shiny app that uses a "refresh" button

    library(shiny)
    library(shinyjs)
    
    jscode <- "shinyjs.refresh = function() { history.go(0); }"
    
    ui <- fluidPage(
      useShinyjs(),
      extendShinyjs(text = jscode),
      textInput("text", "Text"),
      actionButton("refresh", "Refresh app")
    )
    
    server <- function(input, output, session) {
      observeEvent(input$refresh, {
        js$refresh();
      })
    }
    
    shinyApp(ui = ui, server = server)
    

    Edit: Since shiny version 0.13.0, it's possible to refresh the page using Shiny's session$reload() function

    0 讨论(0)
提交回复
热议问题