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

163
Visualizações
The Unordered List Data getting destroyed when another dom element is getting clicked? The page is built in aspx

I am trying to display the the data in an Unordered list which is coming from an API. Below is the code how I have implemented it. Its working completely fine and the data gets displayed as well. But as soon as someone clicks on any other buttons the data disappears as if the list is getting destroyed.

<div class="vendorMarketScroll">
     <ul id="vendorMarketList">
     </ul>
</div>

Populating the List (vendorMarket is containing the data from the API):

function makeVendorMarketList(vendorMarket) {
            if (vendorMarket && vendorMarket.length > 0)
            {
                vendorMarket.sort(function (a, b) {
                return (a.marketName < b.marketName) ? -1 : (a.marketName > b.marketName) ? 1 : 0;
                }); 
                for (var market in vendorMarket) {
                    if(vendorMarket[market].marketName){
                        var z = document.createElement('li');
                        z.innerHTML = vendorMarket[market].marketName;
                        document.getElementById("vendorMarketList").appendChild(z);
                    }
                }
            }  
        }

Please help me in understanding the reason behind this, and what is the correct way to implement this?

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

0

The Problem was something different: the page was getting loaded for many places and hence the creation function had to be called from all the places.

It was kinda my mistake, I was new to the solution.

Thanks to all those who invested their time and tried helping me:)

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