How can I open (using code) a closed boxPlus?
https://cran.r-project.org/web/packages/shinydashboardPlus/vignettes/improved-boxes.html
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";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With