Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
Including JS in Shiny module

all.

I have JS code that works in a Shiny App but no longer works when I call it in a module. I assume this problem has to do with name spaces, but I'm at a loss. Help would be greatly appreciated.

Works when not in a module:

actionButton('download_try_2', "Download Plot"),

mainPanel(plotlyOutput("wv_test", height = "650"),
                                     
tags$script('document.getElementById("download_try_2").onclick = function() {
                                     var gd = document.getElementById("wv_test");
                                     Plotly.Snapshot.toImage(gd, {format: "png"}).once("success", function(url) {
                                     var a = window.document.createElement("a");
                                     a.href = url; 
                                     a.type = "image/png";
                                     a.download = "plot.png";
                                     document.body.appendChild(a);
                                     a.click();
                                     document.body.removeChild(a);
                                     });
                                     } ')

When I try:


actionButton(NS(id, 'download_try_2'), "Download Plot"),

mainPanel(plotlyOutput(NS(id, "wv_test")),

tags$script('document.getElementById("wv_test-download_try_2").onclick = function() {
                                     var gd = document.getElementById("wv_test-wv_test");
                                     Plotly.Snapshot.toImage(gd, {format: "png"}).once("success", function(url) {
                                     var a = window.document.createElement("a");
                                     a.href = url; 
                                     a.type = "image/png";
                                     a.download = "plot.png";
                                     document.body.appendChild(a);
                                     a.click();
                                     document.body.removeChild(a);
                                     });
                                     } ')


I get the error:

Error in htmltools::validateCssUnit(width) : CSS units must be a single-element numeric or character vector

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda