0

i'm using jquery and jquery seletric plugin and it works fine but i need to refill options data after an ajax call.

$('#mySelectID').empty();
     $.each(myResultAjaxObject, function(i, item) {
         $('#mySelectID').append($('<option>', {
             value: myValue,
             text: imyTextValue
         }));
     });
$('#mySelectID').selectpicker('refresh');

This code run for multiple drop-down list and it fills them correctly, the wrong thing is that mark as selected the first child of each drop-down list.

Probably i'm missing something in the selectpicker update procedure.

Any help would be appreciated.

Davide

1 Answers1

0

try to set some delay and check:

setTimeout(() => {
  jQuery('#mySelectID').selectpicker('refresh');
}, 500);
Durga Prasad
  • 81
  • 1
  • 9