Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. (function($){
  2.  
  3.  
  4. $(document).ready(function(){
  5.  
  6. var bz_searchManager = {
  7.  
  8. _searchValues : [],
  9.  
  10.  
  11. run: function() {
  12. var self = this;
  13.  
  14. $('.select_xxx').on('change',function(){
  15.  
  16. var attrName = $(this).attr('data-attribute-name'); // gender
  17.  
  18. var attrValue = $(this).val(); // Male
  19.  
  20. self._searchValues[attrName] = attrValue;
  21.  
  22.  
  23. });
  24.  
  25.  
  26. },
  27.  
  28.  
  29. sortTheDogs: function() {
  30. var self = this;
  31. $('.dog-post').each(function(){
  32.  
  33.  
  34.  
  35. var isValid = true;
  36.  
  37. for( var i in self._searchValues ) {
  38. var attributeName = i;
  39. var attributeValue = self._searchValues[ i ];
  40.  
  41. console.log( attributeName, attributeValue);
  42. // js "equal" for comparing 2 strings
  43. // dont forget to compare if the self._searchValues[ i ];
  44. if( $(this).attr('data-' + attributeName ) != attributeValue ) {
  45. isValid = false;
  46. }
  47. }
  48.  
  49.  
  50. if( isValid == true ) {
  51. // show the dog
  52. } else {
  53. // hide the dog
  54. }
  55.  
  56.  
  57. });
  58. },
  59.  
  60. };
  61.  
  62.  
  63. bz_searchManager.run();
  64.  
  65.  
  66.  
  67. });
  68.  
  69. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement