From 7920dde13e47c81c08136ba470dd2c64eee63d70 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 27 Apr 2017 09:54:24 -0400 Subject: [PATCH] adding test round of header search filters for categories added ajax and php search filtering using sql queries in the ajax search file and the headSearch js file. this should filter the categories based on user selection --- js/app.js | 232 +++++++++++++++++++++----------------- js/custom/headerSearch.js | 232 +++++++++++++++++++++----------------- lib/ajax-search.php | 180 +++++++++++++++++------------ 3 files changed, 368 insertions(+), 276 deletions(-) diff --git a/js/app.js b/js/app.js index c922d08..c336853 100644 --- a/js/app.js +++ b/js/app.js @@ -20,7 +20,7 @@ $(document).ready(function () { } - var activities = page.find('#activities-search'); + var activities = page.find('#activity-search'); var counties = page.find('#county-search'); var cities = page.find('#city-search'); var regions = page.find('#region-search'); @@ -106,22 +106,23 @@ $(document).ready(function () { }); // categories on change -// activities.on('change', function(){ -// $('option:selected', this).attr('selected', 'selected'); -// var activity = this.value; -// var taxonomy = $('option:selected', this).attr('data-taxonomy'); -// jQuery.ajax({ -// type:"POST", -// dataType: 'json', -// url: ajaxurl, -// data: { -// action: "trailmaps", -// activity: activity, -// taxonomy: taxonomy -// }, -// success:function(data){ -// var activity_data = data; -// + activities.on('change', function(){ + $('option:selected', this).attr('selected', 'selected'); + var activity = this.value; + if(activity === ''){ + activity = 'false'; + } + jQuery.ajax({ + type:"POST", + dataType: 'json', + url: ajaxurl, + data: { + action: "trailmaps", + activity: activity, + + }, + success:function(data){ + var activity_data = data; // option = {}; // $('#trail-counties option').not(':eq(0), :selected').remove(); // var selected = $('#trail-counties option:selected').val(); @@ -133,8 +134,8 @@ $(document).ready(function () { // counties.append(option); // } // }); -// -// + + // option = {}; // $('#trail-cities option').not(':eq(0), :selected').remove(); // var selected = $('#trail-cities option:selected').val(); @@ -147,41 +148,49 @@ $(document).ready(function () { // cities.append(option); // } // }); -// -// if( $('#trail-activities option:selected').val() === 'default'){ -// option = {}; -// activities.empty(); -// activities.append($('