let x = data.elem.checked;
data.elem.checked = !x;
form.render();

完整代码

form.on('switch(is_enable)', function (data) {
    let _this = $(this);
    let id = _this.parent().parent().data('id');

    let x = data.elem.checked;
    data.elem.checked = !x;
    form.render();
    //询问框
    layer.confirm('确定启用吗?启用后将不可编辑。', {
        btn: ['确定', '取消'] //按钮
    }, function () {
        $.ajax({
            type: 'POST',
            url: 'setEnable',
            data: {'id': id},
            dataType: 'json',
            success: function (res) {
                if (res.errno == 0) {
                    window.location.reload();
                } else {
                    layer.msg(res.errdesc);
                }
            },
            error: function () {
                layer.msg("网络错误");
            }
        });
    }, function () {
    });
});

相关文章:

  • 2021-11-28
  • 2021-12-27
  • 2021-08-25
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
猜你喜欢
  • 2021-11-05
  • 2022-12-23
  • 2021-04-30
  • 2021-12-26
  • 2021-10-19
  • 2022-12-23
  • 2021-05-15
相关资源
相似解决方案