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

185
Visualizações
Adding bootstrap 'selectpicker' class makes control dissapear

I need to change according to each user a select with companies. I make an ajax call to retrieve the complete select element, if the element contents the "selectpicker" class it gives no error but remains hidden (I guess, just realizing of that class thing took two hours). Retrieving it without any class shows the element, and if I add it later with classListAdd is hidden again. If I load a select with that class from the begining it appears ok. Code below. I put the text of the select retrieved in 'response' for this question.

if(ajaxRequest.readyState == 4){
    var response = ajaxRequest.responseText;
    console.log(response);
    document.getElementById('companies').innerHTML = '<select id="select-multiple"  data-size="10" data-width="100%" multiple data-live-search="true" title="Seleccione Empresa" multiple data-selected-text-format="count"><option value="58">-</option><option value="28"> C.A.P.S.A. Capex</option></select>';
    document.getElementById('select-multiple').classList.add('selectpicker'); //without this line element shows, with it nothing shows
    var testArray = document.getElementById('empresas').value.split(',');
    $('#select-multiple').val(testArray); //no javascript error (element should exists)
    $('#select-multiple').trigger("change");

    }
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