0

I'm trying to get myself a selector that will work with both the search and filtering together, right now it works from the beginning if you choose the selector at start. But choose something else after and the filtering on counteries/serach will break.

I also have a small problem, when I am searching at my tag TE, I will get up all tags starting with the letters TE. I just want the tags how have TE in thier name pops up and If I search for another tag like "SKATE" I only want the tags with "SKATE" in their names shows up, if it is possible.

Like, Te = only stores with TE in thier tagname shows up Skate = only stores with SKATE in their tagname shows up etc..

Right know = searching on Te, Te and & Skate shows up...

  $('select').on( 'change', function() {
        var filterValue = this.value;
        $container.isotope({ 
        filter: filterValue 
        });
        return false;
  });

here is a Jsfiddle

grateful for answers.

1 Answers1

0

If you'd like to switch the filtering to an extact match, you can change your regular expression to indicate as such. For example, on line 57 of the fiddle change:

nameRegex = new RegExp( $quicksearch1.val() , 'gi' );

to this:

nameRegex = new RegExp( '^' + $quicksearch1.val() + '$' , 'gi' );

You're also likely going to want to escape the input for use in a regular expression (Escape string for use in Javascript regex).

Community
  • 1
  • 1
oliakaoil
  • 1,555
  • 1
  • 15
  • 33