In running the below MWE code, the user drags items from the panel on the left to the panel on the right. Note that as items are dragged from the left "Drag from" panel, that list depletes. Is it possible to make those list elements (defined in labels = c(...)
in the first add_rank_list()
function below) reactive, so that the list is never depleted, always containing A, B, C, D, E in this example, regardless of how many times the item has been dragged over? In other words, ever time the user drags an item to the right, an observer is triggered and that same list of A, B, C, D, E is generated again?
This is similar to the cloning feature available in the sortable package, except that I understand cloning can't be used with this far simpler bucket_list(add_rank_list(...))
syntax.
MWE:
library(shiny)
library(sortable)
ui <- fluidPage(htmlOutput("rankingForm"))
server <- function(input, output, session) {
output$rankingForm <- renderUI({
fluidRow(
br(),
column(tags$b("Ranking"), width = 12,
bucket_list(header = "Drag items to the right panel:",
group_name = "bucket_list_group", orientation = "horizontal",
add_rank_list("Drag from Pool:",
labels = c("A","B","C","D","E"), # make labels reactive?
input_id = "rank_list_1"),
add_rank_list("Drag to:", labels = NULL,
input_id = "rank_list_2"))
)
)
})
}
shinyApp(ui=ui, server=server)