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

146
Vistas
Open distant bootstrap modal
let readcomment = event.target.closest(".read-comment");
        let dataAttribute = readcomment.getAttribute('data-id');
        let url = "../comments/" + dataAttribute + "/";
        fetch(url)
            .then(function (response) {
                return response.text();
            })
            .then(function (data) {
                console.log(data)
            })
            .catch(function (error) {
                console.log(error);
            });

When "read-comment" is clicked, I get the data-id value and build the URL variable.

I get the data from the URL with JS fetch function.

I would like to render fetched data in a bootstrap modal (using bootstrap 5)

On bootstrap, documentation says we can create a modal with

var myModal = new bootstrap.Modal(document.getElementById('myModal'), options)

In my project, the "Read-comment" button is in the first file and "myModal" content is in a second different file, and then when the button is clicked, the previous code return :

TypeError: this._element is undefined"

The problem is "document.getelementbyid("myModal")" returns null because myModal is in another file that is not loaded on the first page.

How should I do?

Thank you for your help.

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