layui.table怎样给td添加select
done:function(res,cur,count){
var ct=1;
$("tbody td[data-field='robot'] .layui-table-cell").each(function(e,a){
ct++;
var arry = new Array();
if(!util.isEmpty(a.innerText)){
arry = a.innerText.split(",");
}
$(a).html($(htmlSelects).attr("xm-select","robot"+ct)[0]);
user.formSelects.render('robot' + ct , {
template: function(name, value, selected, disabled){
return value.name; //+ '<span style="position: absolute; right: 0; color: #A0A0A0; font-size: 12px;">' + name + '</span>'
}
});
user.formSelects.value('robot' + ct, arry);
user.formSelects.on('robot' + ct, function(id, vals, val, isAdd, isDisabled){
//id: 点击select的id
//vals: 当前select已选中的值
//val: 当前select点击的值
//isAdd: 当前操作选中or取消
//isDisabled: 当前选项是否是disabled
//alert("当前选择了: " + JSON.stringify(vals));
var select =$("tbody div select[xm-select="+id+"]");
var tt =select.parent().parent().siblings();
var id="";
tt.each(function(e,a){
if($(a).attr("data-field")=="id") id=$(a).children().html();
});
var arr = new Array();
for ( var i = 0; i <vals.length; i++){
arr.push(vals[i].value);
}
user.setRobot(id,arr);
}, true);
})
}
<div class="layui-input-inline">
<select name="quiz2">
<option value="">请选择具体信息</option>
<option value="杭州">1001</option>
<option value="宁波" disabled="">0203</option>
<option value="温州">0708</option>
<option value="温州">0906</option>
<option value="温州">0304</option>
</select>
</div>