0

I have a large amount of selectize elements, one of which is "gender". Gender can, as one would expect, be male and female. If you search for any substring which match male, so m, ma, mal, male it will still highlight female and upon tab select that one.

Is there any way I can override this behaviour? I don't know if it's a bug in sifter, but I suspect what happens is that "empty" is after "fe", so ØØmale is lower ranked lexicographically than female. Which makes no sense though.

enter image description here

Dennis
  • 909
  • 4
  • 13
  • 30

1 Answers1

0

It is just that Selectize matches in the whole string, not only at start. I give a solution in the Filter by only first letter · Issue #795.

To repeat it here: Add this to your options:

  score: function (search)
  {
    return function (option)
    {
//      console.log(JSON.stringify(option));
      if (option.name.indexOf(search) === 0) // Here, 'name' is the property identified by labelField
      {
        return 1;
      }
      return 0;
    }
PhiLho
  • 40,535
  • 6
  • 96
  • 134