If you are new to selectizeInput, I'd recommend you to spend a few
hours on the documentation of selectize.js if you want to use its
advanced features (such as in this app):
https://github.com/brianreavis/selectize.js
There are a few problems in your server.R:
1. server = FALSE does not work when choices is not a character
vector; you have to use the server-side selectize input.
2. In options, you have to specify 1) labelField so that selectize
knows what to show in the text field after you make the selection, 2)
searchField so that selectize knows which column to search in when you
type in the text field, and 3) valueField so that selectize knows what
value to return after you make the selection.
3. 'value' is not a column in your choices data frame, so
escape(item.value) will not work.
Here is a revised version of your server.R that fixes all the three
problems above:
library(shiny)
shinyServer(function(input, output, session) {
# update the render function for selectize
updateSelectizeInput(
session, 'cars', server = TRUE,
choices = cbind(name = rownames(mtcars), mtcars),
options = list(labelField='name', searchField='name',
valueField='name',render = I(
"{
option: function(item, escape) {
return '<div><strong>' + escape(
item.name) +
'</strong><span>(MPG: ' + item.mpg +')</span></div>';
}
}"))
)
})
Regards,
Yihui