I am using jQuery isotope plugin to sort and filter elements. Elements are products having multiple filter groups. I am facing one issue, I need to filter products with multi select filter attribute in same group example:
Filter Groups: Gender, Product category, Product material.
Sample select : Men, Bag, Leather.
Above sample works fine.
But I need something like
New filter selection: Men, Bag, Wallet, leather, Rexin.
If you notice Bag and Wallet are from same group. And leather and Rexin are from same group.
for doing this I would need filter value to be passed like
filtervalue - .men.bag.leather,.men.wallet.leather,.men.bag.rexin,.men.wallet.rexin.
This sounds easy, but I am finding difficult to code this.
I have array of each filter group, which I am updating when the user selects or deselects a particular filter
So essentially, what I need is combining or grouping multiple filter arrays into one string with each group containing every element from each array and each group separated with a comma.
Arrays in javascript:
var gender = ['.men'];
var type = ['.bag','.wallet'];
var material = ['.leather','.rexin'];
Output:
".men.bag.leather,.men.wallet.leather,.men.bag.rexin,.men.wallet.rexin"
Hope I am clear on what I need.
Help much appreciated.
Update:
Since the filters can vary on different products, I am unable to use hardcoded variables like gender, type etc. So instead I am using filters array
var selectedFilter = [];
selectedFilter['gender'] = ['.men'];
selectedFilter['type'] = ['.bag','.wallet'];
selectedFilter['platform'] = ['.leather','.rexin'];
Need Output like, ".men.bag.leather,.men.wallet.leather,.men.bag.rexin,.men.wallet.rexin"
Need some function which I can directly pass one array variable. like
combine(selectedFilter);