当事情发生时,我正试图手动折叠一个盒子.似乎我只需要将类添加"collapsed-box"到框中,我尝试使用shinyjs函数addClass,但我不知道如何做到这一点,因为一个盒子没有id.这里是可用于测试可能解决方案的简单基本代码:
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
box(collapsible = TRUE,p("Test")),
actionButton("bt1", "Collapse")
)
)
server <- function(input, output) {
observeEvent(input$bt1, {
# collapse the box
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)