jQuery不需要在history.back(-1)上重置DOM

jQuery Unwanted resetting of the DOM on history.back(-1)

本文关键字:DOM 不需要 history back jQuery      更新时间:2023-09-26

我在这个网站上使用了下面的脚本http://ronnidc.dk...

当用户检查例如[jan]时,下面的地图上会出现一个点。当用户单击该点时,地图下方会出现一个包含子页面的"阅读更多"链接的摘要文本。这一切都按预期进行。

问题1:问题是当用户通过(历史-1)链接返回到首页时。然后,所有复选框都被清除,点和摘要文本被设置回基准。除了在Firefox中,它在Firefox中运行得很好。我想这个问题与除Firefox之外的所有其他浏览器中的DOM都被重置有关?(我希望当用户返回到带有地图的页面时,复选框选择、地图上的点和所选的摘要文本仍然可见)。

 nbsp如何避免此问题?有某种直播功能吗(从jQuery 1.7中弃用)

问题2:当用户选中[all]时,所有复选框都会按预期进行选中。但为了有意义,复选框[All]的选择应该在其他复选框之一未选中时消失(剩余复选框应保持选中状态)

 nbsp如何做到这一点

/**functions.js**/ 
$(document).ready(function () {
/* =Filtering - (mark the map with dots)
----------------------------------------------- */
    $(function () {
        $('#filtering :checkbox.checkall').click(function () {
            $(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
        });

            $("#filtering :checkbox").attr('checked', null); //uncheck checkboxes on page reload in Firefox
            $("#filtering :checkbox").click(function() {
                $("#pageTeaser article mark").hide();
                $("#filtering :checkbox:checked").each(function() {
                    $("." + $(this).val()).show();
                });
            });
    });

/* =Teaser Show - (Showing teaser text when clicking the dot's)
----------------------------------------------- */
    $('#pageTeaser article mark').click(function() {
        $('#pageTeaser article .inner').hide();
        $('#pageTeaser article .inner').removeClass('active');
        $(this).siblings('.inner').show();
        $(this).siblings('.inner').addClass('active');
    });
});

您必须将该状态(所有复选框状态)存储在某个地方:cookie、location.hash、url……也许history.js可以在这里提供任何帮助。