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

295
Views
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
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!