同位素过滤器不适用于稍后添加到主项目选择器的子项

时间:2016-10-16 04:33:09

标签: isotope

我使用metafizzy提供的同位素在div上使用不同的滤镜,这对我来说效果非常好。但是,当我稍后将一个孩子div添加到ID为div的{​​{1}}时,同位素过滤器对该孩子不起作用。

communitymembers

事件虽然在追加之后我已经调用同位素但它不起作用。

         $container = $('#communitymembers').isotope({
              itemSelector: '.item-select',
              filter: function() {
                    var $this = $(this);
                    var searchResult = commMemberKeywordSearchFilter ? $this.find('.memberName').text().match( commMemberKeywordSearchFilter ) : true;
                    var expertiseResult = $this.is(commMemberExpertiseFilter);
                    var distanceResult = commMemberDistanceFilter ? $this.find('.communityLocation').attr("data-com-loc") < parseInt(commMemberDistanceFilter) : true;
                    return searchResult && distanceResult && (expertiseResult || commMemberExpertiseFilter=='');
                }
            });
               $('.filtercheck').change( function() {
                var inclusives = [];

                $('.filtercheck').each( function( i, elem ) {   
                    if ( elem.checked ) {
                        inclusives.push(elem.value);                                                   
                    }                     
                });
                commMemberExpertiseFilter = inclusives.join(', ');
                $container.isotope();              
            }); 
            $('#distance-filter-community-member-list').on("change", function() {
                commMemberDistanceFilter = this.value;
                $container.isotope();            
            });

            $("#communityMemberListSearch").keyup(debounce(function(){                         
                commMemberKeywordSearchFilter = new RegExp( $("#communityMemberListSearch").val(), 'gi' );
                $container.isotope();
            } , 200));

请帮助!!!

1 个答案:

答案 0 :(得分:0)

修复此问题,

$container.append(template).isotope('appended', template).isotope('layout');

那应该有效