layui动态渲染,初始化默认值
var html = '';
html += '<select name="" lay-search lay-verify="required" lay-filter="iconTypeSelecter" >';
data.forEach(function(elem){
if(elem['id'] == projectTypeId){
html += '<option selected="selected" value="'+elem.id+'">'+elem.name+'</option>';
}else{
html += '<option value="'+elem.id+'">'+elem.name+'</option>'; // 默认选择项
}
});
html += '</select>';
$('#krpanoEditContainer .projectLayer').html(html);
layui.form.render('select'); // 触发select渲染(所有select),填选择器会报错
change事件监听
看到好多文章说用form.on(‘select(<lay-filter>)’,functon(e){}),可怎么都不行。亲测以下用法是可以の:
form.on(‘select’,functon(e){});