弹框之优化

//这里主要是把以前大量重复的代码优化了,只捡弹框思路
//注意 doHref的用法 ,因为每个li传参不同,以致于可以点击每个div可以弹出上面不同数据的sheet1 ,因为doHref里面的参数赋值为全局变量,所以,sheet1下每个DOM的点击事件都可以获取到post返回的不同id或者其他数据
<section class="ny_cont">
<ul class="mui-table-view mui-table-view-chevron tm_list">
</ul>
</section>
<div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">
<ul class="mui-table-view">
<li class="mui-table-view-cell">
<a href="javascript:void(0)" id="tel">打电话</a>
</li>
<li class="mui-table-view-cell">
<a href="javascript:void(0)" id="confirmBtn">请假</a>
</li>
<li class="mui-table-view-cell">
<a href="javascript:void(0)" id="confirmBtn2">签到</a>
</li>
<li class="mui-table-view-cell">
<a href="javascript:void(0)" id="confirmBtn3">取消签到</a>
</li>
</ul>
<ul class="mui-table-view">
<li class="mui-table-view-cell">
<a href="#sheet1"><b>取消</b></a>
</li>
</ul>
</div>

var phone;
var id;
function doHref(i,n){
id=i;
phone=n;
mui('#sheet1').popover('toggle');
}
$.post('/signIn/getMember.json',{'sid':'${sid}','gid':'${gid}'},function(data){
console.log(data)
var dl =data.data;
for (var i=0;i<dl.length;i++) {
var id=dl[i].id;
var name=dl[i].name;
var number=dl[i].number;
var phone=dl[i].phone;
var head=dl[i].head;
var type=dl[i].type;
if( type == 0){
//未签到
$(".tm_list").append('<li class="mui-table-view-cell" onclick="doHref(\''+id+'\',\''+phone+'\')">'
+'<span id='+id+'><span class="count_inst_nbt n_qj">未签到</span></span>'
+'<div class="mui-slider-handle">'
+'<div class="mui-table-cell">'
+'<img style="border-radius: 50%;" class="mui-media-object mui-pull-left" src="'+head+'">'
+'<div class="mui-media-body">'
+name
+'<p class="mui-ellipsis">学号:'+number+'</p>'
+'<p class="mui-ellipsis">手机号:'+phone+'</p>'
+'</div>'
+'</div>'
+'</div>'
+'</li>')
}

弹框之优化

评论 ( 0 )
最新评论
暂无评论

赶紧努力消灭 0 回复