javascript - 应用过滤器后同位素搜索功能停止工作
问题描述
所以我的代码有这个未知问题,一切似乎都运行良好;搜索有效,过滤器有效,但是当我在应用过滤器后尝试搜索时,它不再有效。
$('.select').on('click', '.filter-dropdown', function() {
var parent = $(this).closest('.select');
if (!parent.hasClass('is-open')) {
parent.addClass('is-open');
$('.select.is-open').not(parent).removeClass('is-open');
} else {
parent.removeClass('is-open');
}
}).on('click', 'ul>li', function() {
var parent = $(this).closest('.select');
parent.removeClass('is-open').find('.filter-dropdown').text($(this).text());
$('.filter-item').removeClass('active');
$(this).addClass('active');
var selector = $(this).attr('data-filter');
$('.japps-container').isotope({
filter: selector
});
return false;
});
var qsRegex;
var japps = $('.japps').isotope({
// options
itemSelector: '.japps-item',
layoutMode: 'fitRows',
filter: function() {
var $this = $(this);
var searchResult = qsRegex ? $this.text().match(qsRegex) : true;
return searchResult;
}
});
var $quicksearch = $('.filter-search').keyup(debounce(function() {
qsRegex = new RegExp($quicksearch.val(), 'gi');
japps.isotope();
}, 1));
function debounce(fn, threshold) {
var timeout;
threshold = threshold || 100;
return function debounced() {
clearTimeout(timeout);
var args = arguments;
var _this = this;
function delayed() {
fn.apply(_this, args);
}
timeout = setTimeout(delayed, threshold);
};
}
请参阅下面的 CodePen 链接以查看完整代码。
代码:https ://codepen.io/bonafideboss/pen/oNeyMbQ
我找不到问题。请指教。提前致谢。
解决方案
推荐阅读
- jquery - JQuery隐藏可折叠菜单点击其他任何地方 - 模糊 -
- java - 我的 JList 没有显示
- algorithm - 绘制最大长度为 4 的 BFS 图形
- javascript - 在 React.js 和 sass/css 中隐藏带有过渡的汉堡侧边栏
- java - 如何在 iText 7 中查找文本位置和边界
- c++ - 读取和写入文件
- python - 如何使用python和selenium将文本发送到类型属性为隐藏的输入元素
- sql-server - 在 ASP.NET Core 应用程序中使用 Entity Framework Core 和 SQL Server 2017 的多个租户
- python - 在同一个项目中使用 Python2 和 Python3
- c# - 我的连接字符串应该是什么?