码迷,mamicode.com
首页 > 其他好文 > 详细

layui switch 确定之后才变更状态

时间:2019-09-25 17:30:41      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:启用   orm   ble   location   oca   编辑   cat   success   代码   

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 () {
    });
});

layui switch 确定之后才变更状态

标签:启用   orm   ble   location   oca   编辑   cat   success   代码   

原文地址:https://www.cnblogs.com/jiqing9006/p/11586103.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!