我正在尝试禁用 confirmSweetAlert 中的确认按钮,除非 selectizeInput 中有一些输入。似乎有使用 Javascript 的解决方案,例如swal.disableConfirmButton()
and document.getElementsByClassName().disabled = true
,但是当我在 下运行它们时shinyjs::runjs
,这些似乎不起作用。有什么解决方案可以解决这个问题吗?这是我的示例代码:
shinyApp(
ui <- fluidPage(
actionButton("button", "Show Sweet Alert!")
),
server <- function(input, output, session) {
observeEvent(input$button, {
confirmSweetAlert(
session = session,
inputId = "letterSelect",
title = "Select a Letter!",
type = "info",
text = tags$div(
h4("Please select from the options below then press 'Confirm'.", align = "center"),
selectizeInput(
inputId = "letters",
label = NULL,
choices = c("A", "B", "C"),
options = list(placeholder = "None selected."),
multiple = TRUE,
width = '100%')
),
closeOnClickOutside = FALSE
)
})
}
)