LayUI设置事件和联动下拉框
说明:
1、form.on(‘select(FeiYongDaLei)’, function(data):必须与
<div class="layui-input-inline">
<select name="FeiYongXiaoLei" id="FeiYongXiaoLei" lay-filter="FeiYongXiaoLei">
<option value=""></option>
</select>
</div>
<script>
layui.use('form', function(){
var form = layui.form;
var $ = layui.jquery;
form.on('select(FeiYongDaLei)', function(data){
var InputID = data.value;
var url ="{:U('E/addchk')}"+"?InputID="+InputID+"&type=2";
$.getJSON(url, function(data){
var optionstring = "";
$.each(data.data, function(i,item){
optionstring += "<option value=\"" + item.code +":"+ item.name + "\" >" +item.code +":"+ item.name + "</option>";
});
console.log('item--2:',optionstring);
$("#FeiYongXiaoLei").html('<option value=""></option>' + optionstring);
form.render('select'); //这个很重要
});
});
});
</script>
2、事件绑定消息:
<div class="layui-form" lay-accordion="">
<div class="layui-colla-item">
<h2 class="layui-colla-title">订单信息一览表</h2>
<div class="layui-colla-content layui-show">
<table class="layui-table" lay-size="sm" id="Tbl_DingDan" lay-filter="Tbl_DingDan"></table>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="AnZhuang">安装</a>
<a class="layui-btn layui-btn-xs" lay-event="GuanLi">管理</a>
</script>
</div>
</div>
</div>