Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!