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

Multiple attributes? #33

Closed barcar closed 8 years ago

barcar commented 8 years ago

Is it possible to search multiple attributes? Text, title? Or to have a custom hidden data attribute which can be searched?

barcar commented 8 years ago

I figured out that the attributes listed in the documentation are just examples - you can use any attribute. So I added a "data-keywords" (HTML5) attribute to my items and then included the following code to combine, keywords, title and text into this attribute before initialising HideSeek:

// Append Text and Title to HideSeek search keywords to all FormsItem objects
$('.FormsItem').each(function(index) { $(this).attr('data-keywords', $.trim($(this).attr('data-keywords')) + ' ' + $.trim($(this).text()) + ' ' + $.trim($(this).attr('data-original-title')) );

Combining this with option:

attribute: 'data=keywords'

which tells HideSeek to use the combined field did the trick.