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

135
Visualizações
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
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