继这篇文章之后,我想知道为什么当我单击单元格呈现按钮时不会触发showModal()
内部?observeEvent()
我给按钮一个固定的 ID '字符',observeEvent()
然后打开模态框。但它没有。
如果我在 ShinyApp UI 中放置一个按钮,会在哪里对observeEvent()
inputid 做出反应,或者如果我将它放在可反应中,那么区别在哪里?
library(shiny)
library(reactable)
library(tidyverse)
data = dplyr::starwars %>%
select(name, height, mass, sex, species, homeworld)
ui = fluidPage(
column(width = 6, style = "margin-top: 50px;",
reactableOutput("table"))
)
server = function(input, output, session){
output$table = renderReactable({
reactable(data = data,
height = 600,
defaultPageSize = 20,
columns = list(
name = colDef(
cell = function(value){
div(htmltools::tags$button(value, class = "action-button", id = "character"))
})))})
observeEvent(input$character, {
showModal(modalDialog(title = "Test"))
})
}
shinyApp(ui, server)