0
我想在加載頁面時顯示預先選擇的過濾器。同位素過濾效果很好,過濾器可以應用,但我不想在加載頁面時看到「全部」,所以我試圖在代碼中添加預先選定的過濾器。我究竟做錯了什麼?同位素過濾器:加載過濾器
$('body').on('click touchstart', 'section.gallery .gallery-filters .filter', function(event) {
event.preventDefault();
var isotope = $(this).parent().parent();
var isotopeID = isotope.data('isotope-id');
var filterValue = $(this).data('filter');
martanianLuxuryApartmentsIsotopes[isotopeID].isotope({ filter: filterValue });
isotope.find('.gallery-filters').children('.filter').removeClass('filter-active');
$(this).addClass('filter-active');
//SHOW THE SELECTED FILTER
isotope({
itemSelector: '.filter',
filter: '.gallery-filter-building'
});
isotope.find('.gallery-single-image').removeClass('isotope-element-visible');
var filteredElements = martanianLuxuryApartmentsIsotopes[isotopeID].isotope('getFilteredItemElements');
for(var i = 0; i < filteredElements.length; i++) {
var filteredElement = $(filteredElements[i]);
filteredElement.addClass('isotope-element-visible');
};
});