4

I am using PerpetuumSoft.Knockout library to bind autocomplete to textbox in my asp mvc application as follow:

var myCustomBinding = "...";
var text = knockoutHtml.Hidden();
text.Items.Add(new KnockoutBindingStringItem("autocomplete", myCustomBinding));

The default behavior of knockout autocomplete is firing the autocomplete field immediately after the first character was typed. I want to customize this behavior to force knockout autocomplete control to fire autocomplete field after 3 characters were typed. I don't want to validate text if there are a minimum of 3 characters typed.

I search similar question but I only need to show autocomplete after the third character was typed I don't need any other custom additional behavior.

What I must bind to knockout autocomplete (in myCustomBinding variable)? How to set the minimum length of search text?

greendino
  • 416
  • 3
  • 17
ElConrado
  • 1,477
  • 4
  • 20
  • 46

1 Answers1

3
$(".buttonclass").typeahead({
    source: function (query, process) {
        //your source code
    },
    items: 10,
    autoSelect: false,
    minLength: 3,
    hint: true, //to highlight matching item
    highlight: true,
    afterSelect: function (item) {
        //your code
    },
    matcher: () => {
        return true;
    },
});
ElConrado
  • 1,477
  • 4
  • 20
  • 46
Rameshkumar
  • 264
  • 1
  • 12