【发布时间】:2019-01-02 01:56:17
【问题描述】:
问题
在删除removeUI 的控件时,如何删除/使相应的input 元素无效?
您可以在下面的reprex 中看到,即使在删除textInput 之后,input$x 仍然是“真实的”。理想情况下,我可以告诉shiny input$x 不再有效,任何依赖input$x 的reactives 都将其视为空。
更新
到目前为止阅读答案,我想我并不清楚我想要实现什么。我真的很想知道是否可以在概念上“取消”input$x。在这种情况下,我不必担心有什么东西会破坏生产线。
Reprex
library(shiny)
ui <- fluidPage(
div(textInput("x", "Text"), id = "killme"),
actionButton("del", "Delete"),
verbatimTextOutput("out")
)
server <- function(input, output) {
output$out <- renderPrint(req(input$x))
observeEvent(input$del, removeUI("#killme"))
}
shinyApp(ui, server)
【问题讨论】:
-
removeUI("#out")?还是我误会了? -
out只是为了说明input$x仍然存在。所以我不关心output$out本身,但我真的很想取消input$x。 -
我不知道,但也许
session$sendInputMessage("x", NULL)。 -
好主意,但不幸的是没有工作:(