R Shiny: Present a ShinyBS Modal Popup on page visit (no user action)

后端 未结 2 2143
太阳男子
太阳男子 2020-12-19 22:49

I used bsModal successfully in my code before. However, I can\'t seem to get a modal pop up to show just when the user visits an app\'s first page by default. I thought some

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 23:20

    You can use toggleModal to manually trigger the popup from the server.

    library(shiny)
    library(shinyBS)
    
    ui <- fluidPage(
      mainPanel(
        bsModal(id = 'startupModal', title = 'Dum Dum', trigger = '',
                size = 'large', p("here is my mumbo jumbo")),
        width = 12
      )
    )
    
    server <- function(input, output, session) {
      toggleModal(session, "startupModal", toggle = "open")
    }
    
    shinyApp(ui = ui, server = server)
    

提交回复
热议问题