Shiny 如果用户单击链接,如何显示模式对话框?

Shiny 如果用户单击链接,如何显示模式对话框?,shiny,modal-dialog,Shiny,Modal Dialog,如果用户单击链接,我想显示一个模式对话框。当前,如果用户单击“操作”按钮,“模式”对话框将工作 欢迎提出任何意见。谢谢 ## app.R ## server <- function(input, output) { observeEvent(input$act_guide, { showModal(modalDialog( h5("Data Guidelines"), tags$ol( tags$li("Must have Resp_

如果用户单击链接,我想显示一个模式对话框。当前,如果用户单击“操作”按钮,“模式”对话框将工作

欢迎提出任何意见。谢谢

## app.R ##

server <- function(input, output) {

  observeEvent(input$act_guide, {
    showModal(modalDialog(

      h5("Data Guidelines"),

      tags$ol(
      tags$li("Must have Resp_ID as the first column, occasion_ID as second and dependent variable as the third"), 
      tags$li("Must have no missing value in any fields")
      ), easyClose = TRUE, footer = NULL)
      )
    })
}

ui <- fluidPage(

  h4("Data guidelines"),
  br(),
  actionButton("act_guide", "Click Here!")
)

shinyApp(ui = ui, server = server)
##app.R##

服务器您可以使用
actionLink
而不是
actionButton
来触发弹出窗口,如下所示

library(shiny)
library(shinyBS)

if(interactive()){
  shinyApp(
    ui <- fluidPage(
      h4("Data guidelines"),
      br(),
      actionLink(inputId = "link1", label = "Click Here!")
    ),

    server = function(input, output, session){

      observeEvent(input$link1, {
        showModal(modalDialog(
          h5("Data Guidelines"),
          tags$ol(
            tags$li("Must have Resp_ID as the first column, occasion_ID as second and dependent variable as the third"), 
            tags$li("Must have no missing value in any fields")
          ), easyClose = TRUE, footer = NULL)
        )
      })

    }
  )
}
library(shiny)
library(shinyBS)

if(interactive()){
  shinyApp(
    ui <- fluidPage(
      h4("Data guidelines"),
      br(),
      actionLink(inputId = "link1", label = "Click Here!"),

      bsModal(id = "modal1", title = "Test Modal", trigger = "link1",
              h5("Data Guidelines"),
              tags$ol(
                tags$li("Must have Resp_ID as the first column, occasion_ID as second and dependent variable as the third"),
                tags$li("Must have no missing value in any fields")
              ), easyClose = TRUE, footer = NULL)
    ),

    server = function(input, output, session){

    }
  )
}