我使用shinyWidgets
中的pickerInput
,我想禁用它。为此,我使用了shinyjs
包中的disable
函数,但它不起作用。但当我使用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)
如何解决这个问题?
如果你能帮助我,我会很感激的
你可以把它用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)