I have a below shiny code, I am trying to disable single radio button choice from grouped radio buttons.
I can disable complete radio button using shinyjs::disable()
function. But, having trouble disabling single choice.
library(shiny)
library(shinyjs)
library(shinyWidgets)
if (interactive()) {
ui <- fluidPage(
useShinyjs(),
radioGroupButtons(inputId = "somevalue", choices = c("A", "B", "C")),
verbatimTextOutput("value")
)
server <- function(input, output) {
output$value <- renderText({ input$somevalue })
shinyjs::disable(id="somevalue")
}
shinyApp(ui, server)
}
You can do
runjs("$('input[value=B]').parent().attr('disabled', true);")
or
runjs('$("#somevalue button:eq(1)").attr("disabled", true);')
or
disable(selector = "#somevalue button:eq(1)")