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

129
Vistas
How to store the response from post method globally inside the modal window?

I have a modal where list of title are displayed at left panel and its subcomponents are displayed at right side. This is the code, which will fetch all data in single array.

Array

[
    0 => [
        "title" => 'Title A',
        ....
        "subComponents" => [
        ]
    ],
    1 => [
        "title" => 'Title B',
        ....
        "subComponents" => [
        ]
    ]
]

Modal

$.post(url, {identification: identification}, function (res) {
    let parsedResponse = JSON.parse(res);
    $(".items-body").html('');
    $(".level-wrapper-right-up").html('');

    if (parsedResponse.success) {
        let records = parsedResponse.data;

        for (let j = 0; j < records.length; j++) {
            itemBodyContent.push("<div class='items-body-content left-heading'><span>" + records[j].title + "</span></div>");
        }

        levelWrapperRightUp.push("<div class='title'>" + records[0].heading + records[0].title + "</div>");
    }
    $(".items-body").html(itemBodyContent.join(''));
    $(".level-wrapper-right-up").html(levelWrapperRightUp.join(''));
});

$("#componentModal").modal();

Now when I make selection on title, its sub-components must also change.

$(".items-body").on("click", "div.left-heading", function() {
    alert($(this).text());
});

Since all my required data are already inside records. Is it possible to fetch on div.left-heading click without calling the POST method ?

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