Allow multiple panels to be open at one time
I need to allow multiple panels to be open at one time.
The attached file provides the function bs_multi_open, which modifies the HTML generated by bs_accordion to (1) enable/disable multiple panels to be open at one time and (2) specify which (if any) panels are initially open.
This solves #35.
Example use:
shinyApp(
ui = fluidPage(
tags$h2("Multiple Open Panels, Panels 1 and 3 open at page load"),
bs_accordion(id = "beatles") %>%
bs_set_opts(panel_type = "success", use_heading_link = TRUE) %>%
bs_append(title = "John Lennon", content = "Rhythm guitar, vocals") %>%
bs_append(title = "Paul McCartney", content = "Bass guitar, vocals") %>%
bs_append(title = "George Harrison", content = "Lead guitar, vocals") %>%
bs_append(title = "Ringo Starr", content = "Drums, vocals") %>%
bs_multi_open(
multi=TRUE,
open=c(1,3)
),
tags$h2("One Open Panel, No panels open on page load."),
bs_accordion(id = "fruit") %>%
bs_set_opts(panel_type = "info") %>%
bs_append(title = "Apples", content = "An apple a day keeps the doctor away.") %>%
bs_append(title = "Bannana", content = "Watch out for bannana peels!") %>%
bs_append(title = "Kumquat", content = "What is a kumquat?!") %>%
bs_multi_open(
multi=FALSE,
open=c()
)
),
server = function(input, output) {}
)
Which yields:

I'm sorry that I don't have time to properly create a pull request for this.
I've created pull request #113 to add this functionality through the new function bs_accordion_multi.
Thanks for this cool enhancement. I added the function (bs_multi_open) in the .txt to my shiny script. When I set multi = TRUE and open = c(1,3), the first and third panels are initially open, but when I click on a new panel, only the new panel remains open. Is that the intended behavior? Or are all three panels supposed to remain open until the user clicks on an open panel to close it?