-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pasting multiple items into selectizeInput #1663
Comments
Hello - were you able to find a solution? I'm running into the same issue. |
It looks like you have to add a shinyApp(
ui = fluidPage(
selectizeInput("x", "Choose:",
letters,
multiple = TRUE,
options = list(
delimiter = ',',
create = I("function(input, callback){
return {
value: input,
text: input
};
}")
)
)
),
server = function(input, output) { }
)
# Copy and paste a,b,c,d I found this by trying it with just Javascript here: https://jsfiddle.net/winstonchang/462qjrru/1/ Note that this will also attempt to create entries that don't exist. That's how the Instead of However, to get it from R to Javascript takes a little more work - you can't pass a Javascript regex directly, but you can pass an immediately-invoked function that returns a regex. shinyApp(
ui = fluidPage(
selectizeInput("x", "Choose:",
letters,
multiple = TRUE,
options = list(
splitOn = I("(function() { return /[,;]/; })()"),
create = I("function(input, callback){
return {
value: input,
text: input
};
}")
)
)
),
server = function(input, output) {
}
)
# Copy and paste 1,2,3,4,5;6;7 |
Here is an example of built off of @wch's solution that allows paste input to selectize dropdowns, but this version only accepts values that are present in the options list. shinyApp(
ui = fluidPage(
selectizeInput(
"x",
"Choose:",
letters,
multiple = TRUE,
options = list(
splitOn = I("(function() { return /[,; ]/; })()"),
create = I("function(input, callback){
var selectize_options = $('#x')[0].selectize.options;
if (selectize_options[input] == undefined) {
return {};
} else {
return {value: input, label: input};
}}")
)
)
),
server = function(input, output, session) {
}
)
# example paste: a,1,b,2,c,3,d,xyz;f hello g
|
I'm building an application which uses selectize inputs with multiple = TRUE. I was looking for a way to allow users to paste in a comma separated list of items instead of having to enter each one in individually. It looks like selectize.js supports this as of version 0.12.0 (see here).
Is there a way to do this in Shiny? I tried setting both delimiter and splitOn in options but neither seemed to have any effect.
The text was updated successfully, but these errors were encountered: