[英]R Shiny include button that collapses one part and expands another part of a panel
我希望扩展我在 R shiny 仪表板中的按钮的功能,该仪表板现在可以折叠或展开菜单的一部分。 目前我使用以下类型的按钮
HTML('<button class="inline" data-toggle="collapse" data-target="#demo">Collapse Menu</button>')
菜单的#demo 部分在单击时折叠/展开。 单击按钮时,我还想折叠另一个菜单(具体来说,我想折叠#demo并展开另一个ID,例如#example,反之亦然)。
我会使用图书馆shinyjs。 function 拨动开关,给定和 ID,可以满足您的需求。
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
actionButton(inputId = "go",label = "Button"),
div(id="div_a","Hello There",style="background-color:red;"),
div(id="div_b","General Kenobi",style="background-color:green;")
)
server <- function(input, output, session) {
hide(id = "div_b")
observeEvent(input$go,{
toggle(id = "div_a",anim = T)
toggle(id = "div_b",anim = T)
})
}
shinyApp(ui, server)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.