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

[Suggestion] Allow adding the .no-results class to items that should appear if there are no results #46

Open YPCrumble opened 7 years ago

YPCrumble commented 7 years ago

Thanks for building this library! I appreciate that it's more design oriented than some of the alternatives. I've been able to quickly incorporate it into sites without hassle which has been fantastic.

My suggestion:

I'd like to create an alternate method for the current nodata option. My issue is that I would like my nodata option to include html markup. Currently this isn't possible because it's added via jQuery's text method.

My suggestion is to allow the user to add a class to any items that should be hidden unless the search returns nothing. This is similar in functionality to the exclude option, except that these items would be hidden by default and revealed if there is no match, whereas exclude items are shown by default.

If the nodata flag is passed, we would still remove these list items as an override.

Would a PR for this be welcome? Thanks for your consideration!

YPCrumble commented 7 years ago

@vdw for now I'll use the suggestion in #34, I believe that's the current suggested implementation. Feel free to close this if you think that's the best solution.

YPCrumble commented 7 years ago

My current workaround is to change .text to .html and add my nodata string as HTML. I'm somewhat concerned it could lead to an XSS vulnerability but the input is not generated by the user.