Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Shiny selectize.js item creation

selectize.js has an item creation option as mentioned on http://brianreavis.github.io/selectize.js/. I'm trying to add the same feature in an R Shiny implementation of selectize but unable to figure out how.

Thanks for your help!

PS: Some more details about what exactly I'm doing - I have some sort of free text vector that I let the user add to. However, I want Shiny to prompt the user with the existing free text values that have previously been added in case the user wants to repeat one of them.

like image 485
TheComeOnMan Avatar asked Mar 04 '26 00:03

TheComeOnMan


1 Answers

All you have to do is to set create option to true:

library(shiny)
shinyApp(
  server = function(input, output, session) {
      observe({ print(input$foo) })
  },
  ui = fluidPage(
    selectizeInput(
       "foo", "foo", c(), selected = NULL, multiple = TRUE,
       options = list(create = TRUE))
  )
)
like image 180
zero323 Avatar answered Mar 05 '26 15:03

zero323



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!