rstudio / sortable

R htmlwidget for Sortable.js
https://rstudio.github.io/sortable/
Other
127 stars 30 forks source link

filter in sortable_options does not work #91

Closed BahgatN closed 1 year ago

BahgatN commented 1 year ago

Sorry i am new to the package, I am just trying to undestand how the rank_lis() function works, i just want to make the element "one" unmovable where the user can drag the other elements, can someone explain why this code does not work?

library(sortable)
rank_list(
  text = "You can drag, drop and re-order these items:",
  labels = c("one", "two", "three", "four", "five"),
  input_id = "example_2",
  options = sortable_options(filter = ".ignore-one", disabled = FALSE)
)
andrie commented 1 year ago

To get this to work, you need to provide the ignore-one class to the element you want to filter. Try this:


library(sortable)
rank_list(
  text = "You can drag, drop and re-order these items:",
  labels = list(
    htmltools::tags$div(class="ignore-one", "one - can't move"), 
    "two", "three", "four", "five"
    ),
  input_id = "example_2",
  options = sortable_options(filter = ".ignore-one")
)