修改

76 阅读1分钟

//修改 $(".table").on("click", ".glyphicon-edit", function () {

            //动态
            var id = $(this).parent().attr("data-id");
            $.ajax({
                url: `http://localhost:3001/content/${id}`,
                type: "GET",
                success: function (res) {
                    if (res.status === 200) {
                        const data = res.data;
                        //静态
                        $(".modal-title").html("修改文章");
                        $("#_id").val(id);
                        $("#title").val(data.title)
                        $("#content").val(data.content)
                        $("#top").prop("checked", data.top)
                        //显示
                        $("#modal-id").modal("show")
                    }
                    console.log(res);
                }
            })

        })
        $('#modal-id').on('hidden.bs.modal', function () {
            $("#_id").val();
            $("#title").val();
            $("#content").val();
            $("#top").prop("checked", false);


        })

1.png