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

Select elements to be ignored when searching #22

Closed mjvezzani closed 7 years ago

mjvezzani commented 8 years ago

Hi,

I've been playing with HideSeek and I quite like it. However, I was wondering if it is possible to tag child elements to not be part of the search. For instance:

<input id="search" name="search" placeholder="Search for something" type="text" data-toggle="hideseek" data-list=".list" />
<div id="myId" class="list">
    <p>Text I want to search</p>
    <span>Text to not be included in search</span>
</div>

I tried adding <span class='ignore'>, but it continued to be included in my search. Is it possible to exclude content in the html document from the search? Thanks!

vdw commented 8 years ago

Hi, in order to ignore an element from the list, you have to add this data-ignore=".ignore" to your code:

<input id="search" name="search" placeholder="Search for something" type="text" data-toggle="hideseek" data-list=".list" data-ignore=".ignore" autocomplete="off" />
<div id="myId" class="list">
    <p>Text I want to search</p>
    <p class="ignore">Text to not be included in search</p>
</div>

or this ignore: '.ignore' if you are using javascript to initiate the plugin:

$('#search').hideseek({
    highlight: true,
    ignore: '.ignore'
});

Here is a working example: https://jsfiddle.net/dkrestos/m06r3go7/

Note: Use only one way to initiate the plugin, either javascript or data attributes.

mjvezzani commented 8 years ago

Hi Dimitris,

Thanks for the response and the JSFiddle. In playing around with it, it appears that only elements that are direct descendants of div#list are able to be ignored. Items with a class of ignore nested more than one level deep will not be ignored, is that correct?

vdw commented 8 years ago

In generally, nested lists differ from the require structure that HideSeek supports at the moment.

It will be helpful if you provide me with an example of specific html structure in order to support that feature in the near future.

Thank you, d