Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display message "nothing found'? #39

Open
suntrop opened this issue Oct 23, 2017 · 1 comment
Open

Display message "nothing found'? #39

suntrop opened this issue Oct 23, 2017 · 1 comment

Comments

@suntrop
Copy link

suntrop commented Oct 23, 2017

Is there any chance I can implement something to display "Sorry, nothing found/no matches"? if there is nothing to match in the list? Currently it is just blank.

@R3gi
Copy link

R3gi commented Nov 4, 2018

This should work:

<input id="searchInput" onsearch="javascript:jets.search()" type="search" /><button class="search" onClick="javascript:jets.search()" type="submit">&gt</button>
<ul class="searchable">
	<a href="#1">Item 1</a>
	<a href="#2">Item 2</a>
</ul>

<div id="no_results" style="display:none">No results found</div>

<script>
var jets = new Jets({
	searchTag: '#searchInput',
	contentTag: '.searchable',
	callSearchManually: true,
	didSearch: function(search_phrase) {
		var nr = document.getElementById('no_results');
		var hasResults = $('.searchable a:visible').length;
		if ( ! hasResults) {
			nr.style.display = 'block'; // Results found
		} else {
			nr.style.display = 'none'; // No results
		}
	}
});
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants