javascript - I can't seem to get list.js to filter items with multiple categories -


i'm using list.js sort list of items category. it's easy make work if each list item fits in 1 category, struggling making sort correctly if assigned more 1 category.

this have far on codepen.io

basically, want able tag things both beverage , game. i'm not cycling through array i've created each item's categories correctly... ever acknowledges first item?

there isn't in docs of list.js how use in manner. found issue list.js maintainer marked closed seemed related, told person ask on here, that's i'm trying. https://github.com/javve/list.js/issues/189

i think problem

for (var i=0, j=trythis.length; i<j; i++) {   if (trythis[i] == selection) {     return true;   } else {     return false;   } } 

if first category fits, return true, if first not fit return false, preventing more compares.

you should not return false within loop after loop, when know no category match.

===== update

featurelist.filter(function(item) { 

this call, change list, or return filtered list?

if returns filtered list (as usual way) never saves returned values?

to save values returned filter function assign return value.

list = list.filter(function(i) { }); 

if works in case depends on design of filter function, try it.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -