Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

281
Visualizações
¿Cómo acceder a la identificación de un inputId creado en el servidor?

Tengo una aplicación que, cuando agrego 10 al sliderInput , aparece un botón "OK". Pero no se puede acceder a su inputId en el DOM porque #sbtn1 se creó en el server . Y lo necesito debido a mi necesidad en la aplicación.

Me gustaría acceder a este inputId ( #sbtn1 ) para modificarlo a través de JS ( file.js ) pero no existe.

Mi aplicación:

 library(shiny) library(shinydashboard) header <- dashboardHeader( title = "Dashboard", titleWidth = 300, dropdownMenuOutput( outputId = "drop1" ) ) sidebar <- dashboardSidebar( width = 300 ) jscode <- "$(function() { $('.skin-blue').addClass('sidebar-mini'); }); " body <- dashboardBody( shinyjs::useShinyjs(), shinyjs::extendShinyjs(text = jscode, functions = "JS"), sliderInput( inputId = "one", label = "Registro 1", value = 1, animate = animationOptions( interval = 500, loop = TRUE ), min = 1, max = 10, step = 1, ticks = TRUE ), sliderInput( inputId = "two", label = "Registro 2", value = 1, animate = animationOptions( interval = 500, loop = TRUE ), min = 1, max = 10, step = 1, ticks = TRUE ), valueBoxOutput( outputId = "box1" ) ) ui <- dashboardPage( header = header, sidebar = sidebar, body = body ) server <- function(session, input, output) { fsoma <- function(x) { if (x != 10) { "Error!" } else (actionButton( inputId = "sbtn1", label = "OK", icon = icon("play-circle-o"), style = "color: #f2f2f2; background-color: #333333; border-color: #333333;" )) } fx <- function(x, y) { x + y } fy <- function(x) { x } reac_0 <- reactive({ tibble::tibble( one = input$one, two = input$two, three = input$three ) }) chuveiro <- reactive({ temp <- reac_0() fx( x = temp$one, y = temp$two ) }) luz <- reactive({ temp <- reac_0() fy( x = temp$three ) }) output$box1 <- renderValueBox({ expr = valueBox( value = fsoma(x = chuveiro()), subtitle = "Sum" ) }) } shinyApp(ui, server)

¿Cómo accedo a esta identificación ( #sbtn1 ) para manejarla en mi documento file.js ?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Enlazo la secuencia de comandos después del botón, por lo que la secuencia de comandos se ejecuta cada vez que se crea el botón.

 library(shiny) library(shinydashboard) header <- dashboardHeader( title = "Dashboard", titleWidth = 300, dropdownMenuOutput( outputId = "drop1" ) ) sidebar <- dashboardSidebar( width = 300 ) body <- dashboardBody( sliderInput( inputId = "one", label = "Registro 1", value = 1, animate = animationOptions( interval = 500, loop = TRUE ), min = 1, max = 10, step = 1, ticks = TRUE ), sliderInput( inputId = "two", label = "Registro 2", value = 1, animate = animationOptions( interval = 500, loop = TRUE ), min = 1, max = 10, step = 1, ticks = TRUE ), valueBoxOutput( outputId = "box1" ) ) ui <- dashboardPage( header = header, sidebar = sidebar, body = body ) server <- function(session, input, output) { fsoma <- function(x) { if (x != 10) { "Error!" } else { div( actionButton( inputId = "sbtn1", label = "OK", icon = icon("play-circle-o"), style = "color: #f2f2f2; background-color: #333333; border-color: #333333;" ), tags$script('$(function() {console.log(1); $("#sbtn1").css("background-color", "red");})') ) } } fx <- function(x, y){ x + y} fy <- function(x){x} reac_0 <- reactive({ tibble::tibble( one = input$one, two = input$two, three = input$three ) }) chuveiro <- reactive({ temp <- reac_0() fx( x = temp$one, y = temp$two ) }) luz <- reactive({ temp <- reac_0() fy( x = temp$three ) }) output$box1 <- renderValueBox({ valueBox( value = fsoma(x = chuveiro()), subtitle = "Sum" ) }) } shinyApp(ui, server)

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda