首页 > 解决方案 > 单击时模态消失

问题描述

我的问题是在显示我的新模式时。一旦用户单击模式,它就会消失。

有没有办法解决这个问题?我试图调用下面代码中显示的所有函数。

header <- dashboardHeader(title = "Example")

body <- dashboardBody(mainPanel(DT::dataTableOutput("mytable"), 
                                uiOutput("sd")))
ui <- dashboardPage(header, sidebar, body, skin = "red")
server = function(input, output, session)
{
  
  mymtcars <<- mtcars
  mymtcars$id <<- 1:nrow(mtcars)
  
  
 output$sd <- renderUI({
   lapply(seq_len(nrow(mymtcars)), 
          function(i)
          {
            bsModal(paste0("myModal", i), "Your plot", paste0("btn", i), size = "large", 
                    dataTableOutput(paste0("plot", i)))
          })
 })

  
  iris$new <-  paste0("<a href=\'https://r-studio.vip.ebay.com/shiny/map-analytics/qa/app_topics/',\ target='_blank'>Click Here for Reviews</a>")

  
  output$mytable = DT::renderDataTable({
    
    btns <- shinyInput(actionButton, nrow(mymtcars), "btn", label = "Show modal")
    
    DT::datatable(cbind(Pick = btns, mymtcars),  escape = F,
    options = list(orderClasses = TRUE,
                    preDrawCallback = JS("function() { 
                                         Shiny.unbindAll(this.api().table().node()); }"), 
                    drawCallback = JS("function() { 
                                      Shiny.bindAll(this.api().table().node()); } ")))
  
},server = FALSE)
  
  
  lapply(seq_len(nrow(mymtcars)), function(i)
  {
    
    output[[paste0("plot", i)]] <- renderDataTable(datatable(iris,escape = F, rownames = F))
    
    
    observeEvent(input[[paste0("btn", i)]], {
      toggleModal(session, paste0("myModal", i), "open")
      print("Pressed")
    })
    
  })
}

runApp(list(ui = ui, server = server))

标签: rshiny

解决方案


推荐阅读