Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ($('.hb_header_filter_block').length > 0) {
- let allInputs = $('.hb_header_filter_block input');
- allInputs.on('change', function(event) {
- let allFilters = $('.hb_header_filter_block .filter_list_list');
- let dataArrFilter = eachAllFilters(allFilters);
- // console.log(dataArrFilter);
- $.ajax({
- url: hbFilterCat.url,
- type: 'POST',
- dataType: 'json',
- // dataType: 'default: Intelligent Guess (Other values: xml, json, script, or html)',
- data: {
- action: 'hb_ajax_filter',
- filter: dataArrFilter,
- cat: hbFilterCat.cat_id
- },
- })
- .done(function(data) {
- console.log(data);
- })
- .fail(function(data) {
- console.log(data);
- })
- .always(function() {
- console.log("complete");
- });
- });
- }
- function eachAllFilters(block) {
- let data = [];
- $.each(block, function(index, val) {
- let termName = $(this).data('term');
- let checked = getCheckedInputs($(this));
- data.push({
- termName: termName,
- checked: checked,
- })
- });
- return data;
- }
- function getCheckedInputs(block) {
- let allCheckboxInputs = block.find("input:checkbox:checked");
- let idChecked = [];
- $.each(allCheckboxInputs, function(index, val) {
- idChecked.push($(this).data('term-id'));
- });
- return idChecked;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement