R Shiny 中可排序 rank_list 的句柄

handle for sortable rank_list in RShiny

我用sortable in shiny to create a sortable list where the elements can be dragged and dropped in various positions. According to the documentation (also in the underlying javascript source) you can define handles where you can grab the items and reorder them (https://jsfiddle.net/14je5rmy/,这个fiddle中的X)。

我无法在 shiny 中做同样的事情(即使该选项存在)

library(shiny)
library(sortable)

labels <- list(
  "one",
  "two",
  "three"
)

rank_list_basic <- rank_list(
  labels = labels,
  input_id = "rank_list_basic",
  options = sortable_options(handle=".handle")
)


ui <- fluidPage(
  tags$body(
    tags$span(class="handle", "X"),
  ),
  fluidRow(
      rank_list_basic,
  )
)

server <- function(input, output) {
}

shinyApp(ui, server)

在这个最小示例中,我创建了我想用作 rank_list 中项目的句柄的跨度(“句柄”)。有人能指出我正确的方向吗?

这是创建 jsFiddle 的 R 方法:

library(shiny)
library(sortable)

labels <- lapply(c("one","two","three"), function(i) {
    div(tags$span(class="handle", "X"), tags$span(i))
})

rank_list_basic <- rank_list(
    labels = labels,
    input_id = "rank_list_basic",
    options = sortable_options(handle=".handle")
)


ui <- fluidPage(
    tags$style('.handle {margin: 10px; color:red; background: cyan; border: 1px solid red; cursor: pointer}'),
    fluidRow(
        rank_list_basic
    )
)

server <- function(input, output) {
}

shinyApp(ui, server)