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

有帮助吗?

解决方案

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/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top