sortable_js_capture_input | R Documentation |
This captures the state of a sortable
list. It will look for a data-rank-id
attribute of the first child for each element. If no? attribute exists for
that particular item's first child, the inner text will be used as an
identifier.
sortable_js_capture_input(input_id)
sortable_js_capture_bucket_input(input_id, input_ids, css_ids)
input_id |
Shiny input name to set |
input_ids |
Set of Shiny input ids to set corresponding to the provided
|
css_ids |
Set of SortableJS |
This method is used with the onSort
option of sortable_js
. See
sortable_options()
.
A character vector with class JS_EVAL
. See htmlwidgets::JS()
.
sortable_js and rank_list.
Other JavaScript functions:
chain_js_events()
## -- example-sortable-js-capture -----------------------------------------
# Simple example of sortable_js_capture.
# Important: set the tags CSS `id` equal to the sortable_js `css_id`
if(interactive()) {
library(shiny)
library(sortable)
ui <- fluidPage(
div(
id = "sortable",
div(id = 1, `data-rank-id` = "HELLO", class = "well", "Hello"),
div(id = 2, `data-rank-id` = "WORLD", class = "well", "world")
),
verbatimTextOutput("chosen"),
sortable_js(
css_id = "sortable",
options = sortable_options(
onSort = sortable_js_capture_input(input_id = "selected")
)
)
)
server <- function(input, output){
output$chosen <- renderPrint(input$selected)
}
shinyApp(ui, server)
}
## ------------------------------------
# For an example, see the Shiny app at
system.file("shiny/drag_vars_to_plot/app.R", package = "sortable")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.