//显示模态框内容
function showModal(id, classes, text, callback) {
$(‘#‘ + id + ‘ .‘ + classes).text(text);
$(‘#‘ + id).modal({show:true});
$(‘#‘ + id + ‘ .btn-danger‘)
.off(‘click‘)
.on(‘click‘, function () {
callback();
})
}
//添加等级
function addGrade() {
showModal(‘updateModal‘, ‘modal-title‘, ‘添加推广等级管理‘, function () {
return saveGrade("add");
});
}
//修改等级
function modifyGrade() {
var checkedLength = $(".pro").find(‘input:checked‘).length;
$(‘#modifyModal .modal-title‘).text(‘系统提示‘);
if (checkedLength == 0) {
showModal(‘modifyModal‘, ‘modal-body‘, ‘请选择要修改的数据‘, function () {
});
return false;
}
if (checkedLength > 1) {
showModal(‘modifyModal‘, ‘modal-body‘, ‘只能修改一条数据‘, function () {
});
return false;
}
if (checkedLength == 1) {
var selt = $(".pro").find(‘input:checked‘);
var id = $(selt[0]).attr("level_id");
var showdata = function (data) {
var m = ‘‘;
m += ‘
m += ‘以上日交易笔数为标准‘;
m += ‘%‘;
m += ‘‘;
$(‘#modifyModal .modal-body‘).html(m)
$(‘#modifyModal .modal-title‘).text(‘修改等级[‘ + data.RuleName + "]");
$(‘#id‘).val(data.RuleID);
if (data.Is_Default == 0) {
$("#add input[name=‘isDefault‘]:eq(1)").removeAttr("checked");
$("#add input[name=‘isDefault‘]:eq(0)").attr("checked", ‘checked‘);
}
else {
$("#add input[name=‘isDefault‘]:eq(0)").removeAttr("checked");
$("#add input[name=‘isDefault‘]:eq(1)").attr("checked", ‘checked‘);
}
$(‘#modifyModal‘).modal(‘show‘);
$(‘#modifyModal .modal-footer .btn-danger‘).off(‘click‘).on(‘click‘,function(){
return saveGrade("modify");
})
$("#modifyModal").on("hidden",function(e){$(this).removeData(‘modal‘);});
}
getGradebyId(id, showdata);
}
}
来源: http://www.bubuko.com/infodetail-1947074.html