我使用来自pickerInput的shinyWidgets,我想禁用它。为此,我使用了函数disable form shinyjs包,但它不起作用。但是当我使用selectInput时,这就是工作。这是我的密码:
library(shiny)
library(shinyjs)
library(shinyWidgets)
##### UI ####
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
useShinyjs(),
pickerInput(
inputId = "somevalue",
label = "pickerInput",
choices = c("one", "two")
),
br(),
selectInput(inputId = "test", label = "selectInput",
choices = c("B", "C")
)
)
ui <- dashboardPage(header, sidebar, body)
##### SERVER ####
server <- function(session, input, output) {
shinyjs::disable("somevalue") # doesnt work
shinyjs::disable("test") # ok it's fine
}
shinyApp(ui, server)我们怎么才能修好它?
如能提供帮助,我们将不胜感激。
发布于 2022-05-20 10:52:00
您可以将它封装在div中并禁用它。请注意,这在某种程度上是表面的,使用shinyjs::disable("somevalue")将禁用它,因为不会将任何操作推送到server.R。
library(shiny)
library(shinyjs)
library(shinyWidgets)
library(shinydashboard)
##### UI ####
header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
useShinyjs(),
div(id="somediv",
pickerInput(
inputId = "somevalue",
label = "pickerInput",
choices = c("one", "two")
)
),
br(),
selectInput(inputId = "test", label = "selectInput",
choices = c("B", "C")
)
)
ui <- dashboardPage(header, sidebar, body)
##### SERVER ####
server <- function(session, input, output) {
shinyjs::disable("somediv") # ok it's fine
shinyjs::disable("test") # ok it's fine
}
shinyApp(ui, server)https://stackoverflow.com/questions/72317499
复制相似问题