Creating an item if not already exists in Selectize.js select box and ajax update the new added item

后端 未结 3 757
-上瘾入骨i
-上瘾入骨i 2021-02-05 10:48

I was using Selectize.js in a select box, What i need is, if an item is not in the list of options i would need to add a new item. When new item is added, i want to have an ajax

3条回答
  •  旧时难觅i
    2021-02-05 11:13

    You have to invoke the callback, passing your values:

    $('#fruits').selectize({
        create:function (input, callback){
            callback({
                value: 123, // probably your ID created or something
                text: input
            });
        }
    });
    

提交回复
热议问题