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

javascript - Selectize Options are deleted by remove-button Plugin - Stack Overflow

programmeradmin5浏览0评论

I use the selectize.js with remove-button Plugin. I fill the options dynmaicly based on Users decisions. By Buttonclick i add a new Option.

    $('#saveItem').click(function(){
        data = [{item: 'newItem', nr: 'R005'}];
        var selectize = $item[0].selectize;
        selectize.addOption(data);
        selectize.addItem(data);
        selectize.refreshOptions();
    });

When the user now select the option from the list and later he removes the option from the Inputfield than the option is gone.

Only my inital options are in the optionlist. How can i store the dynamic generated options?

I have a fiddle. There can u see that I get a "Option" newItem by button Click. But when i select and then remove them the "Option" is'nt longer in the option list. Where is my fault?

/

I use the selectize.js with remove-button Plugin. I fill the options dynmaicly based on Users decisions. By Buttonclick i add a new Option.

    $('#saveItem').click(function(){
        data = [{item: 'newItem', nr: 'R005'}];
        var selectize = $item[0].selectize;
        selectize.addOption(data);
        selectize.addItem(data);
        selectize.refreshOptions();
    });

When the user now select the option from the list and later he removes the option from the Inputfield than the option is gone.

Only my inital options are in the optionlist. How can i store the dynamic generated options?

I have a fiddle. There can u see that I get a "Option" newItem by button Click. But when i select and then remove them the "Option" is'nt longer in the option list. Where is my fault?

https://jsfiddle/gwmkmb7r/1/

Share Improve this question asked Jul 29, 2016 at 9:29 fjungfjung 1614 silver badges14 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

This functionality is now added into newer version Just use plugins: ['remove_button']

Add this line in configuration:

persist: true;

More info can be found here.

发布评论

评论列表(0)

  1. 暂无评论