单击后更新 textInput

Update textInput after clicking on it

我只想在单击 textInput 后​​删除它的文本值(放置空白文本)。我尝试了来自 shinyjs 的 "updateTextInput" 或 "onclick" 但没有成功,知道吗?

if (interactive()) {
ui <- fluidPage(
titlePanel("test textInput clicking"),

sidebarLayout(
    sidebarPanel(
        textInput("sequenceTextInput", label = "", value = "Enter sequence 
                   here...")
    ),
    mainPanel(
    )  
))

server = function(input, output) {
}
shinyApp(ui, server)
}

您可以按如下方式将它与 shinyjs 一起使用:

library(shinyjs)

ui <- fluidPage(
  titlePanel("test textInput clicking"),

  sidebarLayout(
    sidebarPanel(
      useShinyjs(),
          textInput("sequenceTextInput", label = "", value = "Enter sequence here...")

    ),
    mainPanel(
    )  
  ))

server = function(input, output,session) {
  onclick("sequenceTextInput",updateTextInput(session,"sequenceTextInput",value=""))
}

shinyApp(ui, server)

希望对您有所帮助!