Materialize CSS - Select Doesn't Seem to Render

前端 未结 14 1179
独厮守ぢ
独厮守ぢ 2020-11-29 20:32

I am currently working with materialize CSS and it seems I\'ve gotten snagged with the select fields.

I\'m using the example provided from their site but unfortunate

14条回答
  •  死守一世寂寞
    2020-11-29 21:17

    First, make sure you initialize it in document.ready like this:

    $(document).ready(function () {
        $('select').material_select();
    });
    

    Then, populate it with your data in the way you want. My example:

        function FillMySelect(myCustomData) {
           $("#mySelect").html('');
    
            $.each(myCustomData, function (key, value) {
               $("#mySelect").append("");
            });
    }
    

    Make sure after you are done with the population, to trigger this contentChanged like this:

    $("#mySelect").trigger('contentChanged');
    

提交回复
热议问题