|
问题描述:bind-click事件绑定后,一次点击会触发多次事件,有时是2次,有时是三次,可能更多
domo结构:
<div class="x-contents-content" xid="teamContent">
<div component="$UI/system/components/justep/list/list" class="x-list"
xid="list3" style="height:100%;" data="teamData" dataItemAlias="teamVal"
autoLoad="true">
<ul class="x-list-template" xid="listTemplateUl3" style="margin-bottom: 0px;">
<div class="col col-xs-4 col-sm-3 col-md-5" xid="div1" style="width:33%;"
bind-click="col1Click" bind-value=" val("id")">
<div component="$UI/system/components/bootstrap/row/row"
class="row" xid="row4" style="display:block;" bind-disable="true">
<img alt="" xid="image1" style="width:100%;display:block;"
height="50px" bind-attr-src=" val("img")" bind-disable="true"/>
<span component="$UI/system/components/justep/button/checkbox"
class="x-checkbox showCheckBox" xid="checkbox2" style="margin:-8px 0;height:5px;text-align:right;"/>
</div>
<div component="$UI/system/components/bootstrap/row/row"
class="row" xid="row1" style="height:40px;width:100%;">
<span xid="span5" class="center-block" style="text-align:center;"
bind-text="val("title")"/>
</div>
</div>
</ul>
</div>
</div>
cilck事件:
Model.prototype.col1Click = function(event){
try{
var self=this;
var ckData=this.comp('ckData');
var obj=$(event.currentTarget).find('input[type="checkbox"]');
var thisVal=$(event.currentTarget).val();
obj.trigger('click');
if (obj[0].checked == true) {//按钮状态
ckData.newData({//选中则新增
"defaultValues":[{'id':self.teamId+'team'+thisVal,'type':'team','fid':self.teamId,'status'bj[0].checked,'val':thisVal}],
"onSuccess":function(){
console.log(ckData.getLastRow().index()); //保存成功输出行标
},
"onError":function(e){
console.log(e)//失败输出错误
}
});
} else{//否则删除
var rows=ckData.find(['type','fid','val'],['team',self.teamId,thisVal]);
$.each(rows,function(k,v){
ckData.deleteData(ckData.getRowByID(v.getID()));
})
}
}catch(e){
var rows=ckData.find(['type','fid','val'],['team',self.teamId,thisVal]);
$.each(rows,function(k,v){
ckData.deleteData(ckData.getRowByID(v.getID()));
})
}
};
|
|