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

284
Visualizações
Why my Select2 initialization looks different with the same function?

I am using javascript to create and animate an html form. Due to action on it, some fields are displayed or not. Some content are dynamically created. I am trying to initialize a select2 after his dynamic creation. I have developped different function.

First of all, the initializeSelect2(element) has you can see below :

enter image description here

This function helps me to initialize different select with same specs.

When I reached my page, an .each() function loop on my select2 to apply the initialization.

enter image description here

So we can get on my web page this view :

enter image description here

So, when you choose an element, some fields are append dynamically to the form. For this, there is a function that created html content, and an other that display these fields on the DOM. When some new content is append, I do the initializeSelect2() function. And surprise, the view of my select on the web page is not the same. As you can see below :

enter image description here

First, i was thinking it was a question of time. Between the moment when the content is created and the moment when the init is doing. But it not seems to be that.

I tried to move the function somewhere else but i always get the same problem. Either the init does not work or the init looks different.

Please if you know a solution or maybe an idea which can help me. Thank you

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