I want to enable/disable a Shiny widget based on the values of 2 other widgets as below -
library(shiny)
library(shinyWidgets)
shinyApp(
ui = fluidPage(
useShinyjs(),
prettyCheckbox(inputId = "Check1", label = "A"),
prettyCheckbox(inputId = "Check2", label = "B"),
uiOutput("Date_UI")
),
server = function(input, output) {
output$Date_UI =
renderUI(dateInput(inputId = "Date",
label = NULL,
width = "80%",
value = Sys.Date(),
min = Sys.Date() - 10,
max = Sys.Date() + 10)
)
observeEvent(c(
input$Check1,
input$Check2
),
{
if (input$Check1 || input$Check2) {
enable('Date')
} else {
disable('Date')
}
})
}
)
With this I want that, if either of Check1 and Check2 is clicked then Date will be enabled. So if both were unselected then Date will be disabled. GUI should start with Date disabled.
Clearly this is not happening with above code? Can you please help to point what went wrong?