谷歌浏览器:
火狐浏览器:
代码:
layui.use('element', function () { var element = layui.element; //监听折叠 element.on('collapse(test1)', function (data) { console.log(data.show); if (data.show) { console.log('a'); } else { console.log('b'); } }) element.on('collapse(test)', function (data) { console.log(data); // var first_area = data; // console.log(first_area_id); // console.log(data); console.log(data.show) var first_area_id = data.content[0].defaultValue; console.log(first_area_id); if (data.show) { //获取场所id // console.log(first_area_id); layui.jquery.ajax({ url: 'getsecrealtime', data: "id=" + first_area_id, type: 'post', success: function (res) { var p = ""; if (res.code == 1) { var count = res.data.length; for (var i = 0; i < count; i++) { p += "<div class='layui-colla-content layui-show' id='morecontent'><p>" + res.data[i].sec_area_name + " 现有人数:" + res.data[i].realtime + " 可容纳人数 " + res.data[i].capacity + "</p></div>"; } } else { p += "<div class='layui-colla-content layui-show' id='morecontent'><p>" + "无数据" + "</p></div>"; // $('#demo'+first_area_id).append(p); } $('#' + first_area_id).append(p); element.render('collapse'); } }); // element.init(); } else { // renderCol(); console.log('b'); $('#' + first_area_id).children('#morecontent').remove(); // $('#'+first_area_id).children('#morecontent').removeClass('layui-show'); } // renderCol(); }); });
全部评论
(0) 回帖