我想访问传递给闪亮模块 UI 组件和模块callModule
内部相应服务器组件的 id。我的意图是使用用户提供的 id 为弹出模式添加标题。
library(shiny)
fooModuleUI <- function(id) {
ns <- NS(id)
list(
actionButton(inputId = ns("show"), label = "Show")
)
}
fooModule <- function(input, output, session) {
# I want to be able to access the id of the module here so that I can use it
# to construct the title to the modal
observeEvent(input$show, {
showModal(
modalDialog(
title = paste0("Add ", "Module id here"), # Want module id here
footer =
div(
modalButton("Cancel"),
actionButton("insert", "Save")
)
)
)
})
}
ui <- shiny::fluidPage(
fooModuleUI("test")
)
server <- function(input, output, session) {
callModule(fooModule, "test")
}
shiny::shinyApp(ui, server)