Great! It works! Thank you!
However, I can not understand why observeEnvent can not detect the change when the last element of selectInput is removed, while observe can see the change.
Is it a bug of observeEnvent?
Thanks!
By the way, it also works (it should) when I put hide and show inside observe.
library(shiny)
library(shinyjs)
app <- shinyApp(
ui = bootstrapPage(
useShinyjs(),
selectInput("sInput", "Select:", choices=1:4, multiple = TRUE),
verbatimTextOutput("vOutput"),
actionButton("btn", "A button")
),
server = function(input, output) {
observeEvent(input$sInput, {
output$vOutput = renderText(input$sInput)
})
observe({
if(is.null(input$sInput))
hide(id = "btn") else
show(id = "btn")
})
}
)
runApp(app)