修复PIX主题片刻评论区反复加载

前言

在我检查每一个页面的样式的时候,偶然发现片刻分类页面的评论区,在反复打开/关闭的时候,就会无限叠加而不是替换,可以去老付的页面试试看音乐片刻分类,并且还发现,在关闭评论区的时候都会请求评论数据表情包

修复步骤

代码位置:pix/inc/assets/js/app.js : 查找 show_comment,替换为以下js代码。

$(document).on("click", ".show_comment", function () {

    $(".blog_list_inner").css("min-height", "calc(100vh)");

    var t = $(this).attr("pid"),
        e = $("#comment_form_reset"),
        a = $(".toi_respond_" + t),
        o = $(".t_com_" + t),
        n = $("#t_commentform").prop("outerHTML");
    o.toggle();

    if (!o.find("form").length) {

        a.prepend(n);

        if (!$(".comment_box_" + t).length) {
            a.after("<div class='comment_box_" + t + " commentshow'></div>");
        }

        e.empty();

    } else {

        e.append(n);
        a.empty();
        $(".comment_box_" + t).remove();

    }
    var i = $(this).parents(".moment_item").siblings("div");

    $.each(i, function () {

        var pid = $(this).find(".show_comment").attr("pid");

        $(".toi_respond_" + pid).empty();
        $(".comment_box_" + pid).remove();
        $(".t_com_" + pid).hide();

    });

    if (o.is(":visible")) {

        var box = $(".comment_box_" + t);
        if (box.length && box.is(":empty")) {

            $.ajax({
                type: "post",
                url: Theme.ajaxurl,
                data: {
                    action: "load_t_comment",
                    pid: t
                },

                beforeSend: function () {

                    box.html('<div class="loading_box"><div uk-spinner></div></div>');

                },

                success: function (res) {

                    box.append(res);

                    $("#comment_post_ID").val(t);
                    $("#comment_parent").val("0");
                    $("#cancel-comment-reply-link").hide();

                    box.find(".loading_box").remove();

                }

            });

        }

    }

})

效果:仅在打开时请求数据,修复评论区无法重置的问题。

总结

就这样,没啥好说的,等老付更新pro啥都会修复。

摸鱼小屋」 (atmoyu.com)版权所有,引用、转载时必须标明原文出处!

消息盒子
# 您需要首次评论以获取消息 #
# 您需要首次评论以获取消息 #

只显示最新10条未读和已读信息