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

129
Views
How to update ion-nav with new data JS

I am trying to implement a nav component as seen on Ionics website. https://ionicframework.com/docs/api/nav

The scenario I want to achive is when a used clicks on the 'click to update' button after clikcing on the item it should call the funtion updateList(). But everytime it is click the error message comes up with: CustomElementRegistry.define: 'nav-home' has already been defined as a custom element"

The whole point is when this function is call then a ajax call will be made (currently commented) and new data will be return to then re-populate the nav component.

My question is how can I avoid this issue I am getting and just update the nav items easily.

Thanks

I have added a JSFiddle link below to replicate the issue

https://jsfiddle.net/pilotman/fq8bh347/1/

    function updateList() {
    
    //Ajax will go here instead of above structure and update techs here instead
    
      customElements.define('nav-home', class NavHome extends HTMLElement {
        connectedCallback() {
          this.innerHTML = `
          <ion-header translucent>
            <ion-toolbar>
              <ion-title>Nav</ion-title>
            </ion-toolbar>
          </ion-header>
          <ion-content fullscreen>
            <ion-list>
            ${techs.map(tech => `
                <ion-item button onclick="showDetail('${tech.title}')">
                  <ion-icon slot="start" name="logo-${tech.icon}" style="color: ${tech.color};"></ion-icon>
                  <ion-label>
                    <h3>${tech.title}</h3>
                  </ion-label>
                </ion-item>
            `).join('\n')}
            </ion-list>
          </ion-content>
        `;
        }
      });
    }
about 4 years ago · Juan Pablo Isaza
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!