Open christianmagill opened 8 years ago
After digging around the source code, I settled on this solution.
testQuery: function (query, txt, _row) { txt = $(_row).attr('data-text'); txt = txt.toLowerCase(); for (var i = 0; i < query.length; i += 1) { if (txt.indexOf(query[i]) === -1) { return false; } } return true; }
Nice imperfect solution!
A custom function option for generating searchable text from elements would be very useful for this and other cases.
I like this a lot so I'll reopen this issue. Thanks!
Great! I look forward to a simpler solution.
I think you're talking about offering a callback like cacheUsing(possibleResult)
that lets you override the functionality applied at https://github.com/DeuxHuitHuit/quicksearch/blob/master/src/jquery.quicksearch.js#L273 and here
So instead of:
var temp = self.strip_html(this.innerHTML);
it would be
var temp = self.strip_html(options.cacheUsing(this));
By default you'd have:
defaults: {
...
, cacheUsing: function(possibleResult) { return possibleResult.innerHTML; }
And override for your scenario
, cacheUsing: function(possibleResult) { return $(possibleResult).data('whatever'); }
Is there any way to search data attributes of the given elements?
A custom function option for generating searchable text from elements would be very useful for this and other cases.