Last active
May 8, 2019 22:53
-
-
Save saurfang/6684a66601a7e5b6467f to your computer and use it in GitHub Desktop.
Selectize Plugins in Shiny
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(htmltools) | |
addUIDep <- function(x) { | |
jqueryUIDep <- htmlDependency("jqueryui", "1.10.4", c(href="shared/jqueryui/1.10.4"), | |
script = "jquery-ui.min.js", | |
stylesheet = "jquery-ui.min.css") | |
attachDependencies(x, c(htmlDependencies(x), list(jqueryUIDep))) | |
} | |
shinyApp( | |
ui = fluidPage( | |
addUIDep(selectizeInput("variables", "", letters, c("a","b","c"), TRUE, | |
options = list(plugins = list("drag_drop", "remove_button")))), | |
textOutput("variables") | |
), | |
server = function(input, output) { | |
output$variables <- renderText(input$variables) | |
} | |
) |
The current shiny
(perhaps even since 1.2.0) seems to be shipped with everything already included, so that all you should need is:
library(shiny)
library(htmltools)
shinyApp(
ui = fluidPage(
selectizeInput("variables", "", letters, c("a","b","c"), TRUE,
options = list(plugins = list("drag_drop", "remove_button"))),
textOutput("variables")
),
server = function(input, output) {
output$variables <- renderText(input$variables)
}
)
(No more need to inject the HTML dependencies. Nice!)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Super helpful! Thanks!