selectize js autocomplete doesnt seem to work
Asked Answered
M

1

13

Please see the following example fiddle :

Although I can select the option from the dropdown, typing doesnt autocomplete. I would expect that when you type B or A you should get the recommendation for banana, apple. Only when of my items in the list is not an existing item it should ask me to add it...

var data = [ "banana", "apple", "orange" ]; var items = data.map(function(x) { return { item: x }; });

$('#input-tags').selectize({
    delimiter: ',',
    persist: false,
    maxItems: 1,
    create:true,
    options: items,
    labelField: "item",
    valueField: "item"
});

Any ideas?

Note the same scenario seems to be working with predefined values : Fiddle

Mothering answered 8/10, 2013 at 12:48 Comment(0)
F
19

You need to add a

searchField: "item"

to the selectize declaration

here's the fixed fiddle: http://jsfiddle.net/wh6Nx/

to add items you need a

create: function(input) {
    return {
        value: input,
        text: input
    }
}

fiddle with both: http://jsfiddle.net/2ZrEu/

Feral answered 8/10, 2013 at 14:3 Comment(2)
Further documentation can be found here: github.com/selectize/selectize.js/blob/master/docs/…Maxia
Spent longer than I liked figuring out why this wasn't working... Thanks.Insolence

© 2022 - 2024 — McMap. All rights reserved.