From f9c5fe8863277875138cfa2132a69df6821262e9 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 14 Apr 2017 09:07:24 -0400 Subject: [PATCH] populating the brands dropdown in the search widget on page load if there are manufacturers retained after a search or a page refresh the brands dropdown should also retain the list of respective brands until a change is made --- glm-member-db/views/front/members/list.html | 84 +++++++++------------ 1 file changed, 34 insertions(+), 50 deletions(-) diff --git a/glm-member-db/views/front/members/list.html b/glm-member-db/views/front/members/list.html index 4effcbe..c14ae96 100644 --- a/glm-member-db/views/front/members/list.html +++ b/glm-member-db/views/front/members/list.html @@ -425,6 +425,7 @@ var categories = '{$categories|@json_encode}'; categories = JSON.parse(categories); + $('#rvManufacturers').on("change", function(){ var _ = $(this); @@ -486,19 +487,6 @@ } else { $("#rvManufacturers").prev().prev().prop("disabled",false); } - // var data = { - // action: 'glm_members_admin_ajax', - // glm_action: 'filterSearch', - - // console.log(response); - // } - // }); -// -// }); -// } -// $('#rvManufacturers').manufacturer_brand(); -// $('#brands').manufacturer_brand(); - }); $('#manufacturer-form').submit(function(e){ if( $('#brands').prev().children('li').length > 0 ){ @@ -506,45 +494,41 @@ } }); -// var cat_ids = []; -// $.fn.manufacturer_brand = function(){ -// -// $(this).on("change", function(){ -// var _ = $(this); -// -// var cat_names = []; -// var cat_id = _.val(); -// var el_id = _.attr('id'); -// var cats = _.prev().find('span'); -// -// cat_ids.push(cat_id); -// -// cats.each(function(){ -// cat_names.push(_.text()); -// }); -// -// var data = { -// action: 'glm_members_admin_ajax', -// glm_action: 'filterSearch', -// cat_ids: cat_ids, -// el_id: el_id, -// cat_names: cat_names, -// }; -// $.ajax({ -// type: 'POST', -// url: '{$ajaxUrl}', -// data: data, -// success: function(response){ -// console.log(response); -// } -// }); -// -// }); -// } -// $('#rvManufacturers').manufacturer_brand(); -// $('#brands').manufacturer_brand(); + jQuery('select[multiple]').asmSelect(); + + if( $('#brands').prev().children('li').length > 0 ){ + $("#rvManufacturers").prev().prev().prop("disabled","disabled"); + } + + if( $('#rvManufacturers').prev().children('li').length > 0 ){ + + $('#brands option').remove(); + var brands = []; + var cat_id = $('#rvManufacturers').val(); + $.each(cat_id, function(index, item){ + var select_id = item; + $.each(categories , function(index, item){ + if( parseInt(select_id) === item.parent_id ){ + brands.push(item); + } + }); + }); + + $.each(brands, function(index, item){ + {literal} var option = $('