在Shiny中删除/插入UI元素

时间:2018-05-17 18:25:48

标签: r shiny

我目前遇到了烦人的问题,我创建了一个observeEvent({})来基于按钮的交替点击添加/删除一些UI元素,但是在添加元素之后,后续点击按钮无法删除它。

    server <- function(input, output,session) {
global <- reactiveValues(add.A = FALSE)
 observeEvent(input$add.A,{
global$add.A = !global$add.A
if(global$add.A){
  insertUI(
  selector = "#heading",
  where = "afterEnd",

  ui =  div(id = "alleles.A",
          fluidRow(
            column(width=6,
              div(div(class="ddown",uiOutput("Recipient.HLA.A.1")),div(class="ddown",uiOutput("Recipient.HLA.A.2")))
            ),
            column(width=6,
              div(div(class="ddown",uiOutput("Donor.HLA.A.1")),div(class="ddown",uiOutput("Donor.HLA.A.2")))
          )
         )
       )
     )
    }else{
      removeUI(selector = "#alleles.A")
    }
  })
}  

0 个答案:

没有答案