zoukankan      html  css  js  c++  java
  • bootstrapSwitch

    一、

    1、bootstrapSwitch 默认选项,加上checked表示true,不加表示false
    <input type="checkbox" id="" name="status" checked data-size="small" value="1">
    2、swich配置
    $('[name="status"]').bootstrapSwitch({
        onText: "上架",
        offText: "下架",
        onColor: "danger",
        offColor: "info",
        size: "small",
        onSwitchChange: function (event, state) {
            if (state == true) {
                $(this).val("1");
            } else {
                $(this).val("2");
            }
        }
    })
    3、触发swich事件
        "switchChange": function () {
            $('[name="switch"]').on('switchChange.bootstrapSwitch', function (event, state) {
                console.log(event);
                if (state == true) {
                    $.get("/gift/updatestatus",
                        { id: $(this).attr("id"), status: '0' },
                        function (data) {
                            console.log(data.result); location.reload()
                        })
                } else {
                    $.get("/gift/updatestatus",
                        { id: $(this).attr("id"), status: '1' },
                        function (data) {
                            console.log(data.result); location.reload()
                        })
                }
            });
        },

    表格的话,需要在加载回调内执行swich配置

                onLoadSuccess: function () {
                    list.initSwitch();
                }
    点到为止
  • 相关阅读:
    PyQt5 -1 最基本的小窗口
    浅谈线段树
    最小生成树问题
    最短路问题
    多重背包问题
    02背包(嘻嘻,完全背包)
    01背包例题
    背包问题(好奇怪)
    关于深搜及广搜
    搜索回溯(第二)
  • 原文地址:https://www.cnblogs.com/fger/p/14803213.html
Copyright © 2011-2022 走看看