Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Allow updating additional attributes in updatePanel #131

Open
warnes opened this issue Dec 19, 2020 · 0 comments
Open

FR: Allow updating additional attributes in updatePanel #131

warnes opened this issue Dec 19, 2020 · 0 comments

Comments

@warnes
Copy link

warnes commented Dec 19, 2020

I would like to be able to programmatically update the title of a bsCollapsePanel, but this is not currently supported.

For example, I would like this to work:

library(shiny)
library(shinyBS)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(HTML("This button will open Panel 1 using <code>updateCollapse</code>."),
                 actionButton("p1Button", "Push Me!"),
                 selectInput("styleSelect", "Select style for Panel 1",
                             c("default", "primary", "danger", "warning", "info", "success")),
                 textInput("p2Title", "Panel 1 Title", value = "Panel 1", width = "100%")
    ),
    mainPanel(
      bsCollapse(id = "collapseExample", open = "Panel 2",
                 bsCollapsePanel("Panel 1", "This is a panel with just text ",
                                 "and has the default style. You can change the style in ",
                                 "the sidebar.", style = "info"),
                 bsCollapsePanel("Panel 2", "This panel has a generic plot. ",
                                 "and a 'success' style.", plotOutput("genericPlot"), style = "success")
      )
    )
  )
)

server <- function(input, output, session) {
  output$genericPlot <- renderPlot(plot(rnorm(100)))
  observeEvent(input$p1Button, ({
    updateCollapse(session, "collapseExample", open = "Panel 1")
  }))
  observeEvent(input$styleSelect, ({
    updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect))
  }))
  # ------- This should change the title of Panel 1 ---------
  observeEvent(input$p1Title, ({
    updateCollapse(session, "collapseExample", title = list("Panel 1" = input$panel1Title))
  }))
  #--------
}

shinyApp(
  ui=ui,
  server=server
)

Please add, :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant