Reputation: 755
Here is an example js to search through and filter the results. http://jsfiddle.net/dfsq/7BUmG/1133/
How is it possible implement something like this?
if(results == null){
console.log("no results");
}
Upvotes: 0
Views: 919
Reputation: 171669
Use a variable to store the filter() results and check it's length against all rows
var $hidden = $rows.show().filter(function() {
text = $(this).text().replace(/\s+/g, ' ');
return !reg.test(text);
}).hide();
$('#no-results').toggle($hidden.length === $rows.length)
Upvotes: 1
Reputation: 3539
Here is a working example, it checks if any rows are visible after searching and hides/shows a "no results" message based on that.
if ($rows.find(':visible').length === 0) {
$("#noResults").show();
}
else{
$("#noResults").hide();
}
Upvotes: 0
Reputation: 1927
Try:
if ($rows.find(':visible').length === 0) {
console.log('no results');
}
Upvotes: 3