Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update noUiSlider from the 15.6.1 to latest one #675

Closed
davide-zinghini opened this issue Mar 13, 2024 · 1 comment
Closed

How to update noUiSlider from the 15.6.1 to latest one #675

davide-zinghini opened this issue Mar 13, 2024 · 1 comment

Comments

@davide-zinghini
Copy link

Hi, i'm using the noUiSliderInput from the package and I need to conditionally disable some handlers. This feature was implemented recently on noUiSlider. How can I update it?

@pvictor
Copy link
Member

pvictor commented Mar 14, 2024

Hello,
Install shinyWidgets from GitHub, then you can try :

library(shiny)
# remotes::install_github("dreamRs/shinyWidgets")
library(shinyWidgets)

ui <- fluidPage(
  noUiSliderInput(
    inputId = "disable_handler",
    label = "Disable specific handler:",
    min = 0, 
    max = 1000, 
    value = c(50, 200),
    color = "#F2DEDE", 
    behaviour = "drag"
  ),
  verbatimTextOutput(outputId = "res_disabled"),
  checkboxInput(
    inputId = "disable_1",
    label = "Disable handler 1",
    value = FALSE
  ),
  checkboxInput(
    inputId = "disable_2",
    label = "Disable handler 2",
    value = FALSE
  )
)

server <- function(input, output, session) {
  observeEvent(input$disable_1, {
    if (input$disable_1) {
      updateNoUiSliderInput(
        session = session,
        inputId = "disable_handler",
        disableHandlers = 1
      )
    } else {
      updateNoUiSliderInput(
        session = session,
        inputId = "disable_handler",
        enableHandlers = 1
      )
    }
  })
  observeEvent(input$disable_2, {
    if (input$disable_2) {
      updateNoUiSliderInput(
        session = session,
        inputId = "disable_handler",
        disableHandlers = 2
      )
    } else {
      updateNoUiSliderInput(
        session = session,
        inputId = "disable_handler",
        enableHandlers = 2
      )
    }
  })
}

shinyApp(ui, server)

@pvictor pvictor closed this as completed Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants