Selectize Options are deleted by remove-button Plugin
Asked Answered
C

2

6

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.net/gwmkmb7r/1/

Clambake answered 29/7, 2016 at 9:29 Comment(0)
G
9

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

Gudrun answered 6/10, 2017 at 8:19 Comment(0)
H
6

Add this line in configuration:

persist: true;

More info can be found here.

Harmonics answered 31/5, 2017 at 9:24 Comment(1)
I really don't know why you got downvoted. This definitely solved the problem. Thanks!Vale

© 2022 - 2024 — McMap. All rights reserved.