I am trying to do the multiple search or filter with ListJS. Looks like my code doesn't work! Like: fist filter the product & then filter with color & then filter with size.
That works for only normal search.
I am trying to do the multiple search as I have two search field.
<div id="users"> <div class="searchbox">
<form action="" method="get">
<input class="search" id="id" placeholder="ID" type="text" />
</form> </div> <div class="searchbox">
<form action="" method="get">
<input class="search" id="d2" placeholder="D2" type="text" />
</form> </div>
<script src="javascript/search/list.js"></script>
<script type="text/javascript">
var options = {
<!-- valueNames: [ 'name', 'type', 'keywords-search', 'd2' ]-->
valueNames: [ 'keywords-search', 'd2' ]
};
var userList = new List('users', options);
</script>
<script src="javascript/search/list.js"></script>
<script type="text/javascript">
var options = {
<!-- valueNames: [ 'name', 'type', 'keywords-search', 'd2' ]-->
valueNames: [ 'keywords-search', 'd2' ]
};
var userList = new List('users', options);
</script>
<script type="text/javascript">
$('#filter-clothes').on('click', function() {
var idFilter = $('#id').text();
var itemFilter = $('#d2').text();
console.log('idFilter: ' + idFilter);
console.log('d2Filter : ' + d2Filter);
console.log('Applying filter now...');
featureList.filter(function(item) {
console.log('Running filter() on item: ('+item+')');
console.log('item.values().id: ' + item.values().id);
console.log('item.values().d2: ' + item.values().d2);
return
(idFilter==='All packages' || item.values().id === idFilter)
&& (d2Filter==='All items' || item.values().d2 === d2Filter);
});
return false;
});
</script>
Any of you guys have any simple example?
Try replacing the "+" with a comma, like so: