Skip to content

Instantly share code, notes, and snippets.

@im-noob
Last active March 3, 2021 07:44
Show Gist options
  • Save im-noob/6165cb11eb76eec48f34d2db26d1d445 to your computer and use it in GitHub Desktop.
Save im-noob/6165cb11eb76eec48f34d2db26d1d445 to your computer and use it in GitHub Desktop.
let certificate_search_ele = $('#certificate-search');
let certificate_list_text_ele = $('.certificate-list-text');
let certificate_category_ele = $('#certificate_category');
function applyFilters() {
/*Search Filter */
let value = certificate_search_ele.val().toLowerCase();
certificate_list_text_ele.filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
/*Drop Down Filter*/
let selected_category = certificate_category_ele.val();
certificate_list_text_ele.each(function(key,value){
if (selected_category !== 'all') {
if (!($(value).attr('certificate_category_id') === selected_category)) {
$(value).hide();
}
}
});
}
$(document.body).on('keyup', '#certificate-search' ,function(){
applyFilters();
});
certificate_category_ele.on('change', function () {
applyFilters();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment