Hi.
Unless I missed it in the docs, there is no way to know how many answers are returned by a searchBar. So here is a quick example as solution. It would be helpfull to be added as a new propertie (for example searchCount
).
var searchbar = app.searchbar.create({
el: '.searchbar',
searchContainer: '.list',
searchIn: '.item-title',
on: {
search: function () {
var all = this.searchContainer.querySelectorAll(this.params.searchIn).length;
var hidden = this.searchContainer.querySelectorAll(".hidden-by-searchbar").length;
var searchCount = all - hidden;
console.log("there are "+searchCount+" answers");
}
}
});
Default value (before any search) should be initialized to this.searchContainer.querySelectorAll(this.params.searchIn).length;