In my Drupal 7 site I have a product overview page built with Views. On that page I have a number of checkboxes that can be clicked on in any order. For each checkbox clicked a corresponding tag is copied into an input text field. This text field is then used as a search field for the jQuery Quicksearch plugin. (I borrowed the idea from here, but I use the new plugin version from deuxhuithuit).
As these checkboxes can be clicked in any order, the tags in the search field are being added in any order.
I then have a big number of divs containing products, where each product have a tag text field, where a number of tag terms can be entered separated only with a space, depending on the characteristics of the products.
Is there any way to make the Quicksearch plugin accept these terms in any order with the help of the options prepareQuery and/or testQuery? If so, how is it done? I have spent many hours trying to find examples for how to do this.
If that is not a possibility, I guess the only option is to build a function that will sort the tags in a certain fixed order in the search field, and then always enter the tag terms in the right order for each product...
Anyhow this is how the setup looks like right now:
$('#searchfield').quicksearch('.views-column .views-field-field-soktaggar', {
'delay': 100,
'selector': 'div.searchtags',
'loader': 'span.loading',
'noResults': '#noresults',
'bind': 'keyup',
'show': function () {
$(this).parent('.views-column').removeClass('hide');
$(this).parent('.views-column').addClass('show');
},
'hide': function () {
$(this).parent('.views-column').removeClass('show');
$(this).parent('.views-column').addClass('hide');
},
'prepareQuery': function (val) {
return new RegExp(val, "i");
},
'testQuery': function (query, txt, _row) {
console.log('query: ' + query + ' txt: ' + txt + ' _row: ' + _row);
return query.test(txt);
}
});