【问题标题】:Get incomplete input from selectizeInput从 selectizeInput 获取不完整的输入
【发布时间】:2017-09-06 01:32:45
【问题描述】:

我正在使用 selectizeInput 以获得可自动完成的单词列表,如下面的应用程序所示。

server <- function(input, output) {
    output$word <- renderText({
        input$selInp
    })
}

ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
            selectizeInput('selInp', label  ='', 
                           selected = 'like',
                           choices = c('like','eat','apples','bananas'))
        ),
        textOutput('word')
    )
)

shinyApp(ui = ui, server = server)

我想做的事情是接收与choices 不匹配的输出。因此,如果我写“橙色”,我希望能够在textOutput 中显示它。有没有办法告诉selectizeInput 不要对输入的内容如此挑剔?

【问题讨论】:

标签: javascript r shiny selectize.js


【解决方案1】:

我相信您正在寻找create 选项:

library(shiny)

server <- function(input, output) {
  output$word <- renderText({
    input$selInp
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      selectizeInput('selInp', label  ='', 
                     selected = 'like',
                     options = list('create' = TRUE),
                     choices = c('like','eat','apples','bananas'))
    ),
    textOutput('word')
  )
)

shinyApp(ui = ui, server = server)

【讨论】:

  • hmm 不完全是因为我猜它会强制用户为自己永久添加它,并且需要一个令人困惑的鼠标单击(添加)。确切的目的是注意到用户输入了错误的内容,阅读他们写的内容并告诉他们“嘿。我看到你正在写,但这不是一个真正的选择。这就是为什么......”虽然这确实符合原来的问题
  • 如果您想要 selectize 不支持的特定内容,您可以寻找支持您所需行为的替代 JavaScript 库。找到要使用的 JS 库后,将其绑定到闪亮的状态并不是太多工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-10
  • 2022-11-30
  • 1970-01-01
相关资源
最近更新 更多