2 issues... in your code.
In your example, I don't understand why you do basic javascript instead of using jQuery.
function populate(s1,s2){
var s1 = document.getElementById(s1);
var s2 = document.getElementById(s2);
s2.innerHTML = "";
if(s1.value == 1){
var optionArray = ["Mikel|John Obi Mikel"];
}
for(var option in optionArray){
var pair = optionArray[option].split("|");
var newOption = document.createElement("option");
newOption.value = pair[0];
newOption.innerHTML = pair[1];
s2.options.add(newOption);
}
$('select').material_select();
}
Yep, @matrix818181 is right, you have to call the material_select() function if it is added dynamically. This is also mentioned in the documentation.
But I'm experiencing a different & very odd problem. I've 5 select's on a bottom sheet modal, The first one let me pick first 5, 2nd one let me pick 3 & rest of them allow only 1 item.
All options shows up but behave like this.
What is going on? no errors on console... Please help
But what to do with the behavior of select closing window every time it updates .
This really helped me @Dogfalo. Thank you so much
Most helpful comment
2 issues... in your code.
In your example, I don't understand why you do basic javascript instead of using jQuery.