bevacqua/horsey

How to limit number of results?

Hurtak opened this issue · 6 comments

If i have larger number of suggestions, how do i limit how much of suggestions are displayed in rendered box?

By filtering out and cutting after x results.

Hi, i am having some trouble implementing it, could you maybe provide code snippet? Thanks.

function horsefy (el) {
  var i = 0, max = 50;
  return horsey(el, {
    filter: function () {
      return i++ < max;
    }
  });
}

This overwrites default filtering which uses fuzzysearch with my own function which just displays first x results. How do i just filter first x results without overwriting default filtering function? Also your function doesn't reset i to 0 so it only works first time i type.

It was just an example. You can deduce how to do the rest yourself, or submit a PR that does it in core

You can now use the limit option