DeuxHuitHuit / quicksearch

A jQuery plugin for searching through DOM Elements quickly
https://www.npmjs.org/package/jquery.quicksearch
Other
135 stars 35 forks source link

Search in double element #9

Closed youpioou closed 10 years ago

youpioou commented 10 years ago

Hello, I saw one bug in quicksearch ad my table. When I use plugin to search one element, sometimes result returns is wrong because my search is done on two elements. For exemple, if my table is :

colonne 1 colonne 2 colonne 3
Line 1 abcde fghi
Line 2 abcd efgh

If i search " de ", line 1 is returns but line 2 too because "d e" is ok for this search. It's possible to resolve this problem is changing the js code ?

Thank you for your help and your reply.

nitriques commented 10 years ago

Thanks for reporting, I'll see what I can do.

For now, are you able to create a better prepareQuery function ?

See https://github.com/DeuxHuitHuit/quicksearch/blob/master/src/jquery.quicksearch.js#L32-L34

youpioou commented 10 years ago

Hi, thank you for your reply. I looked code of jquery.quickseacH.js and I saw where query is created. My problem is resolved if I add space at end this line

Before : var output = input.replace(new RegExp('<[^<]+\>', 'g'), ""); 
After : var output = input.replace(new RegExp('<[^<]+\>', 'g'), " "); 

Now, with input

<td>abcde</td>
<td>fghi</td>

var output is "abcde fghi" and not "abcdefghi" and my search "defh" doesn't work.

Good job on this plugins and I'm happy to use this in my website. And thank you for your help.

nitriques commented 10 years ago

Yeah I think this is a valid fix, will update ASAP. (or please send a PR!)

nitriques commented 10 years ago

Fixed and released under 2.0.5. Thanks!

youpioou commented 10 years ago

No problem, thank you for your job ;).