I have been able to check if its a barcode that has been scanned or keyboard typed into my searchbar, but when i clear the searchbar, it re-renders the already search results starting all over again with the items displayed on page init therefore yielding no results.
var virtualList = app.virtualList.create({
// List Element
el: '.virtual-list',
// Pass array with items
items: this.items,
// Custom search function for searchbar
searchAll: function (query, items) {
var found = [];
for (var i = 0; i < this.items.length; i++) {
if (this.items[i].item.toLowerCase().indexOf(query.toLowerCase()) >= 0 || this.items[i].barcode.toLowerCase().indexOf(query.toLowerCase()) >= 0 || query.trim() === '') found.push(i);
}
!isNaN(query) ? app.searchbar.clear(".page[data-name='catalog'] .searchbar") : '';
return found; //return array with mathced indexes
},