vdw / HideSeek

A simple, mobile-friendly, yet customizable quick/live search jQuery plugin.
http://vdw.github.io/HideSeek
Apache License 2.0
429 stars 74 forks source link

Showing div on no-result #34

Closed Los closed 8 years ago

Los commented 8 years ago

There's some way to show a div or html element when there's no result? Or just apply a class by .addClass option?

Thanks

khodakhah commented 8 years ago

Hi, What do you mean? Where? Which file?

Los commented 8 years ago

$('#faqSearch').hideseek({ list: '.faqItem', ignore: '.collapse' });

I just want to show a div when it get no results.

vdw commented 8 years ago

Hi, the "_after_nodata" event is just added in order to trigger an action when there are no results. So, now you can do something like this:

$('#search').on("_after_nodata", function() {
  $('.my_custom_no_results_div').show();
});

Assuming there is an element like this:

<div class="my_custom_no_results_div" style="display:none">
  <span>No results!</span>
</div>
Los commented 8 years ago

Awesome! Thanks!

ecowed commented 8 years ago

I found using the above code worked, but on re-searching with a found element, the no results part still displayed. I have made an incredibly hacky way around it, but would it be possible to use a callback/function as a valid entry for the nodata option? That way, someone could either specify some text to display, or their own function?