无法使用removeUI删除输入

时间:2017-03-02 06:14:24

标签: r shiny

我有两个输入要从ui.R中删除

fileInput(inputId = "FileInput",label = "Choose a csv file",accept = '.csv'),
uiOutput("SKU")

在服务器内部我使用observeEvent删除这些2 inputs并插入一个。虽然insertUi正在运行,但我无法移除the other 2

PFB 代码:

observeEvent(input$Save,{
    removeUI(
      selector = "div:has(> #FileInput)"     
    )
    insertUI(
      selector = "#Save",
      where = "afterEnd",
      ui =fluidPage( 
        tags$hr(),
        fluidRow(column(offset=0,1,actionButton("clean","Start cleaning the Data")))
      )
    )  
    })

1 个答案:

答案 0 :(得分:0)

似乎你必须以shiny blog example将文本包装在带有id的div中处理文本的方式对待它。

tags$div(
    fileInput(inputId = "FileInput",label = "Choose a csv file",accept = '.csv'),
    id='FileInput'
)

示例

ui <- fluidPage(
   mainPanel(
     tags$div(fileInput('element1','Input file...'),id='element1'),
     actionButton('remove','Remove File Input')
   )
)

server <- function(input, output) {
   observeEvent(input$remove,{
     removeUI(selector = '#element1')
   })  
}

shinyApp(ui = ui, server = server)