<>LayUI Of select Dynamic linkage

To achieve linkage effect, pay attention to two points :

first : You need to be able to listen select Of change event ;

second : Content loaded asynchronously , You need to render it again Normal use .

html code :
<form class="layui-form batchinput-form" action="" id="box-form"> <div class="
layui-form-item" > <div class="layui-input-inline"> <label class="
layui-form-label"> Province :</label> <div class="layui-input-block" > <select name="
province" id="province" lay-filter="myselect"> <option value=""> Please select a province </option> <
#list province as provincelist> <option value="${provincelist.areaId}">
${provincelist.fullname}</option> </#list> </select> </div> </div> </div> <div
class="layui-form-item"> <div class="layui-input-inline"> <label class="
layui-form-label"> City :</label> <div class="layui-input-block"> <select name="
City" id="City" lay-filter="myselect2" > </select> </div> </div> </div> <div
class="layui-form-item"> <div class="layui-input-inline"> <label class="
layui-form-label"> Region :</label> <div class="layui-input-block"> <select name="
Area" id="Area" lay-filter="myselect3"> </select> </div> </div> </div> </form>
layui.use(['layer', 'form',"jquery"], function(){ var layer = layui.layer ,$=
layui.jquery ,form = layui.form; form.on('select(myselect)', function(data){ var
areaId=(data.value).replaceAll(",",""); $.ajax({ type: 'POST', url: ' Access to data url',
data: {" Dynamic parameter name ":areaId}, dataType: 'json', success: function(data){ $("#City").
html(""); $.each(data, function(key, val) { var option1 = $("<option>").val(val.
areaId).text(val.fullname); // adopt LayUI.jQuery Add list item $("#City").append(option1);
form.render('select'); }); $("#City").get(0).selectedIndex=0; } }); }); });
1.select Of chage Monitoring event usage

form.on(‘select(myselect)’, function(data){}) among myselect yes select Of
lay-filter Property value

2. Data is loaded asynchronously into select Of option After middle school , Click the select You'll find out layui The selection effect of does not work , Need to use
form.render(‘select’); Render again , It can be used normally .

©2020 ioDraw All rights reserved
2020 Nobel Prize in physiology or medicine announced Implementation and challenge of metadata service in data Lake Enterprises face SEM Bidding and SEO How to choose ? Or both ?spark.sql.shuffle.partitions and spark.default.parallelism The difference between JavaScript Do a simple guess number games What are the types of variables ? Trump's "VIP therapy ": Is receiving a drug treatment that has not yet been approved ( Essence )2020 year 6 month 26 day C# Class library DataTable( Extension method ) program ( process ) How is it stored in the operating system , Space allocation Understanding neural network machine translation in three minutes