Materialize CSS - Select Doesn't Seem to Render

前端 未结 14 1199
独厮守ぢ
独厮守ぢ 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:23

    The solution that worked for me is by calling the 'material_select' function after the options data has been loaded. If you print out the value of OptionsList.find().count() to the console it's first 0 then a few milliseconds later the list gets populated with data.

    Template.[name].rendered = function() {
        this.autorun(function() {
            var optionsCursor = OptionsList.find().count();
            if(optionsCursor > 0)
            {
                $('select').material_select();
            }
        });
    };
    

提交回复
热议问题