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

189
Vistas
Is it possible to set the inner HTML of an element with a file using d3js?

I am trying to clean up some code that I am writing and I had a thought: Would it be possible to set the inner HTML of a component using d3js like the code below?

d3.select("body").append("div").html(d3.html("../components/modal.html"));

If this is possible, what is needed to make it work, because right now, this only puts a text field on the page that says [object Promise]

Is this only wishful thinking?

EDIT: I am using Bootstrap 5 to implement my modal

UPDATE:
As I described in a comment below, I took the code from @SmokeyShakers answer---

d3.html("../components/modal.html").then((data) => {
      d3.select("body").append("div").html(data)
    })

---and replaced the first .html(...) with .text(...) as so:

d3.text("../components/modal.html").then((data) => {
      d3.select("body").append("div").html(data)
    })

This made it so that the modal would actually render, but the buttons and other functionalities I had built into the modal wouldn't work. And for additional information, my modal buttons did not have an onclick="..." attribute in the inline HTML, but it was added using

d3.select('#my-modal-submit').on('click', ()=>{...})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this out. d3.html is a fetch, so I think you need to go inside out:

    d3.html("../components/modal.html").then((data) => {
      d3.select("body").append("div").html(data)
    })
about 4 years ago · Juan Pablo Isaza Denunciar
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