最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - selectize js autocomplete doesnt seem to work - Stack Overflow

programmeradmin1浏览0评论

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

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

Share Improve this question edited Oct 8, 2013 at 13:48 Athanatos asked Oct 8, 2013 at 12:48 AthanatosAthanatos 1,0897 gold badges15 silver badges33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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/

发布评论

评论列表(0)

  1. 暂无评论