I develop javascript filtering of some results and have some difficulties.
Here is the problem ...
Suppose we have some criteria
- Manufacturer (Trusardi, Calvin Kane, Armani ...)
- Color (red, blue, black ...)
- OtherFeatures (goretex, blah, blah ...)
Each function is displayed as a flag ...
The problem is that I want to turn off the checkboxes if its selection does not lead to any results. For example, Armani products can only have blue color, so the armani check should turn off black and red, but other manufacturers should not be turned off ... as a check they should provide the result ...
Here is the code so far
results = $("#products li");
results.hide();
var filtersGroup = $("#filters li.filtersGroup");
$("#filters li.filtersGroup a").removeClass("disabled");
filtersGroup.each(function(index) {
var classes = "";
$(this).find("a.checked").each(function(index) {
classes = classes + "." + $(this).attr("id") + ",";
});
if (classes == "") return true;
results = results.filter(classes.substr(0, classes.length - 1));
filtersGroup.not($(this)).each(function(index) {
$(this).find("a").each(function(index) {
if (results.filter("." + $(this).attr("id")).length <= 0) {
$(this).removeClass("checked").addClass("disabled");
}
});
});
});
, . , , , , , .
, , , . ( 16 4 12 ..
, ... ?