Advertisement
Beee

filter cities

Apr 8th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.81 KB | None | 0 0
  1. jQuery(document).ready(function() {
  2.  
  3.     var $input_option = '.search-criteria-cities .input_option';
  4.     var $countries    = '.search-criteria-countries';
  5.     var $states       = '.search-criteria-states';
  6.     var $cities       = '.search-criteria-cities';
  7.  
  8.     jQuery($countries + " input").click(function() {
  9.         var country = jQuery(this).attr('class');
  10.  
  11.         if(jQuery('.search-criteria-countries .input_option input.' + country).is(':checked')) {
  12.             jQuery($states + ' .input_option.select_note').addClass('hidden');
  13.             if (jQuery($states + ' .input_option.' + country).hasClass('hidden')){
  14.                 jQuery($states + ' .input_option.' + country).removeClass('hidden');
  15.             }
  16.             // @TODO: also filter cities on change
  17.             // add wildcard for states
  18.             // if (jQuery($cities + ' .input_option.' + country + '*' ).hasClass('hidden')){
  19.             //     jQuery($cities + ' .input_option.' + country + '*' ).removeClass('hidden');
  20.             // }
  21.  
  22.  
  23.         } else {
  24.             // unchecked
  25.             jQuery($states + ' .input_option.' + country).addClass('hidden');
  26.         }
  27.  
  28.     });
  29.     jQuery($states + " input").click(function() {
  30.         var state = jQuery(this).attr('class');
  31.  
  32.         if(jQuery('.search-criteria-states .input_option input.' + state).is(':checked')) {
  33.             jQuery($cities + ' .input_option').addClass('hidden');
  34.             if (jQuery($cities + ' .input_option.' + state).hasClass('hidden')){
  35.                 jQuery($cities + ' .input_option.' + state).addClass('show_anyway');
  36.             }
  37.         } else {
  38.             // unchecked
  39.             jQuery($cities + ' .input_option').addClass('hidden');
  40.             jQuery($cities + ' .input_option.' + state).removeClass('show_anyway');
  41.         }
  42.  
  43.     });
  44.  
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement