You can achieve this by adding an observeEvent function that triggers the modal dialog to show up after the first click of the actionButton. Here's an example code:
library(shiny)
ui <- fluidPage(
actionButton("btn", "Click me"),
fluidRow(
column(12,
tags$div(id = "modalExample", class = "modal fade",
tags$div(class = "modal-dialog",
tags$div(class = "modal-content",
tags$div(class = "modal-header",
tags$h5(class = "modal-title", "Modal Title"),
tags$button(type = "button", class = "close", "×",
data_dismiss = "modal",
aria_label = "Close")),
tags$div(class = "modal-body",
tags$p("This is the modal body text."))
)
)
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$btn, {
if (input$btn == 1) {
showModal("modalExample")
}
})
}
shinyApp(ui, server)
In this code, we added an observeEvent function that listens to the click of the actionButton. If the button is clicked for the first time (input$btn == 1), then the showModal function is called to trigger the modal dialog to show up.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-09-23 11:00:00 +0000
Seen: 11 times
Last updated: Apr 14 '22
In Jetpack Compose Dialog, what is the process for drawing behind the system status bar?
How can we close a nested MatDialog in Angular?
How can I use a modal dialog in conjunction with Vaadin Flow notifications?
In React using Material UI tabs, what is the method to show the initial tab?
What is the reason for Refs to show the current state that has been updated?
Reword this question: How can I rephrase "React SHOW DETAIL button"?
How can I show an image in my Qt project?
How can I set the Flutter Time Picker to show only AM times?