Here is the question, I have two dynamically rendered action buttons that are designed to reload the session, but I have trouble listening to them, it is like an OR action, each of them is clicked and then the session reloads. Here is the code:
ui <- shinyUI(bootstrapPage(
p('cbldwbvkdj'),
uiOutput('aa')
)
)
server <- shinyServer(function(input, output, session) {
output$aa<-renderUI({
actionButton("test1", "test1")
actionButton("test2", "test2")
})
observeEvent(paste0(input$test1, input$test2), {
session$reload()
}, ignoreInit = T)
})
shinyApp(ui, server)
You can add req
to the observeEvent
:
library(shiny)
ui <- shinyUI(
bootstrapPage(
p('cbldwbvkdj'),
uiOutput('aa')
)
)
server <- shinyServer(function(input, output, session) {
output$aa <- renderUI({
tagList(
actionButton("test1", "test1"),
actionButton("test2", "test2")
)
})
observeEvent(list(input$test1, input$test2),{
req(input$test1!=0 | input$test2 !=0)
session$reload()
}, ignoreInit = TRUE,ignoreNULL = TRUE)
})
shinyApp(ui, server)