弹框modal, 获取id与绑定id

1、先绑定属性data-groupClassId
var span2 = '<span class="replaceBlue cursor" data-target="#myModalMember" data-toggle="modal" data-groupClassId="'+groupId+'" >成员管理</span>';

2、modal 弹出

 一、  //成员管理
$('#myModalMember').on('show.bs.modal',function(event){
var groupClassId = $(event.relatedTarget).attr('data-groupClassId'); //获取id 后这里可以直接用
console.log(groupClassId); sercice(sUrl.selectGroupMemberInfo, function(data){
if(data.success){
var GroupMemberInfos = data.body.GroupMemberInfos;
var str='';
if(GroupMemberInfos.length>0){
for(var i=0;i<GroupMemberInfos.length;i++){
var userName = GroupMemberInfos[i].userName;
var courseCount = GroupMemberInfos[i].courseCount;
var isMember = GroupMemberInfos[i].isMember; str+='<div class="clearfix item">';
str+= '<span class="pull-left">'+userName+'-'+courseCount+'节</span>';
str+= '<span class="pull-right">';
str+= '<input type="checkbox" id="awesome_'+i+'" onclick="checkBox(this)">';
str+= '<label for="awesome_'+i+'"></label>';
str+= '</span>';
str+='</div>';
}
}
$("#selectStu").html(str);
}
}, {
"addressId" : storageAddressId,
"token":token,
"groupClassId":groupClassId
    })
  }); 二、 //成员管理
$('#myModalMember').on('show.bs.modal',function(event){

     var groupClassId = $(event.relatedTarget).attr('data-groupClassId') ; //获取 后这里可以直接用
//给此弹框绑定 后面函数可以直接用
$("#myModalMember").attr('data-groupClassId'
,groupClassId);
abc();

  });
function abc(){
var groupClassId = $("#myModalMember").attr('data-groupClassId',groupClassId); //获取弹框上的id
sercice(sUrl.selectGroupMemberInfo, function(data){
if(data.success){
var GroupMemberInfos = data.body.GroupMemberInfos;
var str='';
if(GroupMemberInfos.length>0){
for(var i=0;i<GroupMemberInfos.length;i++){
var userName = GroupMemberInfos[i].userName;
var courseCount = GroupMemberInfos[i].courseCount;
var isMember = GroupMemberInfos[i].isMember; str+='<div class="clearfix item">';
str+= '<span class="pull-left">'+userName+'-'+courseCount+'节</span>';
str+= '<span class="pull-right">';
str+= '<input type="checkbox" id="awesome_'+i+'" onclick="checkBox(this)">';
str+= '<label for="awesome_'+i+'"></label>';
str+= '</span>';
str+='</div>';
}
}
$("#selectStu").html(str);
}
}, {
"addressId" : storageAddressId,
"token":token,
"groupClassId":groupClassId
    })
}
上一篇:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'like '%逸%'' at line 1


下一篇:jquery特效收藏