2017-04-10 62 views
0

我正在使用selectizeInput来获取自动完成词的列表,如下面的应用程序中所示。从selectize获取不完整的输入输入

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不要对它所需的输入做出如此的选择?

+0

喜欢这个? http://stackoverflow.com/questions/32223770/r-shiny-selectize-js-item-creation –

回答

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) 
+0

嗯不完全一样,我猜它强制用户为自己永久添加它,并需要一个混乱的鼠标点击(添加)。确切的意图是注意用户输入了错误的内容,阅读他们写的内容并告诉他们“嗨,我看到你在写这些,但这不是一个真正的选择,这是为什么......”虽然这符合原始问题 – OganM

+0

如果您想要某些特定选项不支持,您可以查找支持您所需行为的备用JavaScript库。一旦你找到了一个你想使用的JS库,将它的绑定变成有光泽的并不是太多的工作 –