简体   繁体   English

内容在页面加载时消失

[英]The content disappears on page load

So I have this simple issue and I can't figure it out how to get this done. 所以我有一个简单的问题,我不知道该如何完成。 Okay, the thing is that I have this JavaScript which works on to display the content with respect to the menu. 好的,我要使用此JavaScript来显示有关菜单的内容。 Like for example If I choose any thing from the menu it filters the content and shows me the selected item. 例如,如果我从菜单中选择任何东西,它将过滤内容并显示所选项目。 In my case, when the page loads, the content comes for a second and then disappears. 以我为例,当页面加载时,内容出现一秒钟然后消失。 I am not sure why is this happening? 我不确定为什么会这样?

The JS JS

var CombinationFilters = function() {
    var filters = {};
    var container = null;
    var initEvents = function()
    {
        // filter buttons
        jQuery('.isotope-filter-none li').click(function() {  
            // don't proceed if already selected
            if (jQuery(this).hasClass('selected')) {
                return;
            }

            var optionSet = jQuery(this).parent();
            // change selected class
            optionSet.find('.selected').removeClass('selected');
            jQuery(this).addClass('selected');

            var group = optionSet.attr('data-filter-group');             
            filters[ group ] = jQuery(this).children("a").attr('data-filter-value');
            // convert object into array
            var isoFilters = [];
            for (var prop in filters) {
                isoFilters.push(filters[ prop ]);
            }
            var selector = isoFilters.join('');            
            container.isotope({filter: selector});

            return false;
        });

        // remove selected category
        jQuery('.remove-selected-category').click(function() {  
            jQuery(".isotope-filter-drop-down li[menu-top-index='"+jQuery(this).attr('menu-group')+"']").trigger('click');
        });

        // filter buttons from drop down
        jQuery('.isotope-filter-drop-down li').click(function() {  
            // don't proceed if already selected 
            if (jQuery(this).hasClass('choosen')) {
                return false;
            }

            var choosenCategoryName = jQuery(this).attr('choosen-category-name');
            var menuGroupIndex = jQuery(this).attr('menu-group-index');
            if(choosenCategoryName == "") {
                jQuery(".choosen-category[menu-group='"+menuGroupIndex+"']").hide();
            } else {
                jQuery(".choosen-category[menu-group='"+menuGroupIndex+"'] > div").html(choosenCategoryName);
                jQuery(".choosen-category[menu-group='"+menuGroupIndex+"']").show();
            }

            var optionSet = jQuery(this).parent().closest("div");
            // change selected class
            optionSet.find('.choosen').removeClass('choosen');
            jQuery(this).addClass('choosen');

            var group = optionSet.attr('data-filter-group');  

            filters[ group ] = jQuery(this).children("a").attr('data-filter-value');
            // convert object into array
            var isoFilters = [];
            for (var prop in filters) {
                isoFilters.push(filters[ prop ]);
            }
            var selector = isoFilters.join('');            
            container.isotope({filter: selector});            
            return false;
        });

    };

    var initContainer = function() {
        container = jQuery('#container').isotope({
        itemSelector: '.isotope-item' /*,            
            masonry: {
                columnWidth: 80
            } */
        });
    };

    return {
        init: function()
        {              
            initContainer();
            initEvents();
        }
    };
}();

jQuery(CombinationFilters.init);

The HTML HTML

This is the HTML for one the entity in the content, there are more. 这是内容中实体的HTML,还有更多。 I am just providing one so that I could let you guys know about the classes. 我只是提供一个,这样我就可以让大家知道这些课程。

<div class="isotope-item grid-item one-quarter iphone mood symptoms" style="position: absolute; left: 0px; top: 0px; transform: translate3d(0px, 3520px, 0px);">
<article class="tools archive grid four-column">
<div class="image">
<img src="http://localhost/newwplms/wp-content/uploads/2013/09/Symple.jpeg">

<div class="hover">

<a class="action" href="http://localhost/newwplms/tools/symple-symptom-tracker-health-diary/">

<i class="icon-chevron-right"></i></a><a class="action fancybox" href="http://localhost/newwplms/wp-content/uploads/2013/09/Symple.jpeg">
<i class="icon-search"></i></a></div></div><div class="meta">
<h4 class="title">

<a href="http://localhost/newwplms/tools/symple-symptom-tracker-health-diary/">Symple</a></h4>

</div>
</article>
</div>

Your first line of html includes as part of the inline css: html的第一行包含在内联css中:

transform: translate3d(0px, 3520px, 0px);

I'm guessing that you don't have a screen that's 3520 pixels tall! 我猜您没有3520像素高的屏幕! So you're sending the div off the screen. 因此,您正在将div发送到屏幕之外。 Remove that and you'll see your div. 删除它,您将看到div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM