【发布时间】:2020-08-28 19:33:02
【问题描述】:
我正在尝试禁用 confirmSweetAlert 中的确认按钮,除非 selectizeInput 中有一些输入。似乎有使用Javascript的解决方案,例如swal.disableConfirmButton()和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
)
})
}
)
【问题讨论】:
标签: r shiny sweetalert2 shinyjs shinywidgets