Michael Lau
Michael Lau

Reputation: 149

List js multi filter with all

im using list JS with multi filters,

I am using this link for reference http://codepen.io/waynehoover/pen/KBqhF

trying to work around this function

userList.filter(function(item) {
    return (_(values_date).contains(item.values().born) || !values_date) && (_(values_name).contains(item.values().name) || !values_name)
  });
}

but how do i put add "ALL" filter, so example if i choose the "ALL" in the date, it only filters the name and vice versa

Upvotes: 0

Views: 1728

Answers (1)

Zesky
Zesky

Reputation: 524

You may add "ALL" to date or name by

  all_born.push('ALL');
  all_name.push('ALL');

then filter using the script below:

userList.filter(function(item) {
    return (_(values_date).contains('ALL') || _(values_date).contains(item.values().born) || !values_date) 
        && (_(values_name).contains('ALL') || _(values_name).contains(item.values().name) || !values_name)
});

You may reference the following codepen for working example:

http://codepen.io/zesky/pen/JGrYgd

Hope this help :)

Upvotes: 1

Related Questions