Issue in tokeninput when we hit space bar

57 views Asked by At

If I hit space bar then the tokeninput.js hits ajax with empty query string, what to do please help.

<div class="text-field">
  <input type="text" id="tags" name="tag" />
</div>
$("#tags").tokenInput(baseUrl + 'tags-for-course', {
  prePopulate: tags,
  hintText: "Type in a search term",
  searchDelay: 300,
  minChars: 3,
  preventDuplicates: true,
  zindex: 9999,
  theme: "facebook",
  onResult: function(item) {
    return item;
  }
});
1

There are 1 answers

1
tanaydin On

You can set "2" use "minChars" setting of tokenInput. so something like

{
    prePopulate: tags,
    hintText: "Type in a search term",
    searchDelay: 300,
    minChars: 2,
    preventDuplicates: true,
    zindex: 9999,
    minChars: 2
    theme: "facebook",
    onResult: function (item) {
        return item;

    }
}