久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      基于layui實(shí)現(xiàn)select區(qū)域聯(lián)動(dòng)

      基于layui實(shí)現(xiàn)select區(qū)域聯(lián)動(dòng)

      要實(shí)現(xiàn)聯(lián)動(dòng)效果注意兩點(diǎn):

      第一要可以監(jiān)聽到select的change事件;

      第二異步加載的內(nèi)容,需要重新渲染后才可以 正常使用。

      Html結(jié)構(gòu):

      <div class="x-body">     <form class="layui-form" action="" method="post">         <div class="layui-form-item">             <label class="layui-form-label">選擇地區(qū)</label>             <div class="layui-input-inline">                 <select name="province" lay-filter="province" id="s_p">                     <option value="1">請(qǐng)選擇省</option>                 </select>             </div>             <div class="layui-input-inline">                 <select name="city" lay-filter="city" id="s_c">                     <option value="1">請(qǐng)選擇市</option>                 </select>             </div>             <div class="layui-input-inline">                 <select name="area" lay-filter="area" id="s_x">                     <option value="1">請(qǐng)選擇區(qū)/縣</option>                 </select>             </div>         </div>         <div>             <label class="layui-form-label">選擇地區(qū)</label>             <div class="layui-input-inline">                 <select name="towns" lay-filter="towns" id="s_t">                     <option value="1">請(qǐng)選擇鄉(xiāng)鎮(zhèn)/街道</option>                 </select>             </div>             <!--<div class="layui-input-inline">-->                 <!--<select name="burg" lay-filter="burg" id="s_b">-->                     <!--<option value="1">莊/村</option>-->                 <!--</select>-->             <!--</div>-->         </div>     </form> </div>

      js:

      <script type="text/javascript">      layui.use(['form', 'layer', 'laytpl', 'jquery'], function () {         var form = layui.form             , $ = layui.jquery;          var parentId = '0';         $(function () {             $.post(serverPath + "sys/area/backProvince/" + parentId, function (result) {                 var p = result;                 for (v in p) {                     var pp = p[v].id;                     $("#s_p").append("<option value=" + pp + ">" + p[v].fullname + "</option>")                 }                 form.render();             })              form.on('select(province)', function (data) {                 var p = $("#s_p").val();                 if (p != "1") {                     $.post(serverPath + "sys/area/backProvince/" + p, function (result) {                         var c = result;                         $("#s_c").html("");                         $("#s_c").append("<option value='1'>請(qǐng)選擇市</option>");                         $("#s_x").html("");                         $("#s_x").append("<option value='1'>請(qǐng)選擇縣/區(qū)</option>");                         $("#s_t").html("");                         $("#s_t").append("<option value='1'>請(qǐng)選擇鄉(xiāng)鎮(zhèn)/街道</option>");                         $("#s_b").html("");                         $("#s_b").append("<option value='1'>請(qǐng)選擇村/街道號(hào)</option>");                         for (v in c) {                             var cc = c[v].id;                             $("#s_c").append("<option value=" + cc + ">" + c[v].fullname + "</option>")                         }                         form.render();                     })                 }             });             form.on('select(city)', function (data) {                 var c = $("#s_c").val();                 if (c != "1") {                     $.post(serverPath + "sys/area/backProvince/" + c, function (result) {                         var x = result;                         $("#s_x").html("");                         $("#s_x").append("<option value='1'>請(qǐng)選擇縣/區(qū)</option>");                         $("#s_t").html("");                         $("#s_t").append("<option value='1'>請(qǐng)選擇鄉(xiāng)鎮(zhèn)/街道</option>");                         $("#s_b").html("");                         $("#s_b").append("<option value='1'>請(qǐng)選擇村/街道號(hào)</option>");                         for (v in x) {                             var xx = x[v].id;                              $("#s_x").append("<option value=" + xx + ">" + x[v].fullname + "</option>")                         }                         form.render();                     });                 }             });             form.on('select(area)', function (data) {                 var x = $("#s_x").val();                 if (x != "1") {                     $.post(serverPath + 'sys/area/backProvince/'+ x, function (result) {                         var t = result;                         $("#s_t").html("");                         $("#s_t").append("<option value='1'>請(qǐng)選擇鄉(xiāng)鎮(zhèn)/街道</option>");                         $("#s_b").html("");                         $("#s_b").append("<option value='1'>請(qǐng)選擇村/街道號(hào)</option>");                         for (v in t) {                             var xx = t[v].id;                             $("#s_t").append("<option value=" + xx + ">" + t[v].fullname + "</option>")                         }                         form.render();                     });                 }             });           });     });   </script>

      總結(jié):

      1、select的chage監(jiān)聽事件使用

      form.on('select(myselect)', function(data){}) 其中myselect是select的 lay-filter屬性值

      2、數(shù)據(jù)異步加載到select的option中之后,點(diǎn)擊該select會(huì)發(fā)現(xiàn)layui的選中效果不起作用,需要使用form.render('select');重新渲染一次,就可以正常使用。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)