Reputation: 3774
How can I open (using code) a closed boxPlus?
https://cran.r-project.org/web/packages/shinydashboardPlus/vignettes/improved-boxes.html
Upvotes: 3
Views: 627
Reputation: 2409
I've been looking for answer for the same question and I've figured out how to do this with shinyjs.
library(shinydashboardPlus)
library(shinydashboard)
library(shinyjs)
library(shiny)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
useShinyjs(),
boxPlus(
id = "openable-box-plus",
title = "Openable boxPlus",
closable = TRUE
),
actionButton(
inputId = "open-box-plus",
label = "Open boxPlus"
)
)
)
server <- function(input, output) {
observeEvent(
input$`open-box-plus`,
runjs('
document
.querySelector("#openable-box-plus")
.parentElement
.style.display = "block";
')
)
}
shinyApp(ui, server)
When you check HTML of the boxPlus before and after closing it, you can see that style display: none;
is added to the <div>
with class="box"
.
To select specific boxPlus
I added id = "openable-box-plus"
. Since id
went to the child div
of div
with display
style, you have to select parent element, and change display
to "block"
:
document
.querySelector("#openable-box-plus")
.parentElement
.style.display = "block";
Upvotes: 1