fjung
fjung

Reputation: 161

Selectize Options are deleted by remove-button Plugin

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/

Upvotes: 6

Views: 6051

Answers (2)

user1546085
user1546085

Reputation: 61

Add this line in configuration:

persist: true;

More info can be found here.

Upvotes: 6

Swap-IOS-Android
Swap-IOS-Android

Reputation: 4383

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

Upvotes: 9

Related Questions