点击事件ajax,$(this),点击事件里有点击事件,触发多次ajax,如下图和代码

问题

第一步,点击...,显示红色的罩层

fa653e0ea858177f4f1858315e94d8d4.png

第二步,点击启动答题

b67008ba270386c856cf60499852c791.png

点击了启动答题,就产生问题了

第一次点击的时候,只发一次ajax,第二次点击,就会触发2次,一直叠加

要循环的html

{{=it.paperName}}

{{=it.paperTypeName}}

{{=it.createTime}}

状态:

{{? it.status==="not_start"}}

未答题

{{?? it.status==="started"}}

答题中

{{??}}

结束答题

{{?}}

{{=it.questionCount}}题

{{? it.paperTypeId===6}}

{{=it.className}} - {{=it.studentName}}

{{??}}

{{=it.className}}

{{?}}

已提交0/1

未批改

正确率

{{=it.accuracy}}%

//3个点点点

{{? it.status==="not_start"}}

img

启动答题

img

取消答题

{{?? it.status==="started"}}

img

结束答题

img

开始扫描

img

开始批改

{{??}} {{? it.correctStatus==="not_start"}}

img

开始扫描

img

开始批改

{{??}}

img

批改完成

{{?}} {{?}} {{? it.courseId}}

{{??}}

{{?}}

点击事件

function IndexControl() {

var Red = $('.app-index .index-body .body-item .item-red');

var showRed = $('.app-index .index-body .body-item .item-white .white-right .right-bottom');

// var startBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-start');

var stopBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-stop');

var delBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-del');

var editBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-edit');

var scanBtn = $('.app-index .index-body .body-item .item-red .red-group .group-img-scan');

//显示红色遮罩层

showRed.click(function() {

$(this).parents('.item-white').siblings('.item-red').css('display', 'flex');

$(this).parents('.body-item').siblings().children('.item-red').hide();

$(this).parents('.body-item').siblings('.actived').children('.item-red').show();

var courseId = $(this).parents('.item-white').siblings(".item-red").children('.courseIdindex').val();

classId = $('#selectclassId').val();

piId = $(this).parents('.item-white').find('.this-paperId').val()

testId = $(this).parents('.item-white').children(".white-left").children('.testId').val()

// var startBtn = $(this).parents(".item-white").siblings(".item-red").find(".group-img-start");

// startControl(startBtn, courseId, classId, piId,testId);

//点击启动答题

$(this).parents(".item-white").siblings(".item-red").find(".group-img-start").click(function(event){

event.stopPropagation();

starttest_paper(courseId, classId, piId,testId)

})

stopControl(stopBtn, courseId, classId, piId,testId);

cancelControl(delBtn, courseId, classId, piId,testId);

editControl(editBtn, testId);

scanControl(scanBtn, testId);

});

//隐藏红色遮罩层

Red.click(function() {

$(this).hide();

})

}

ajax

function starttest_paper(courseId,classId,paperId,testId, callback) {

var createBy = $api.getStorage('global_userId');

api.ajax({

url: cbd_server_url + 'exam/start',

method: 'put',

dataType: 'json',

headers:{

"Content-Type":'application/json',

},

data:{

body: {

id: testId,

paperId: paperId,

classId: classId,

courseId: courseId,

createBy:createBy

}

//status: "started"

// })

},

}, function(ret, err) {

if (ret) {

console.log(JSON.stringify(ret))

var result = ret.msg;

callback && callback(result);

} else {

console.log(JSON.stringify(err))

}

})

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值