Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Preservation of original data attibutes and banned values in search - #1194

Closed
fran-diaz wants to merge 1 commit into
selectize:masterfrom
fran-diaz:fran-diaz-patch-1
Closed

fran-diaz wants to merge 1 commit into
selectize:masterfrom
fran-diaz:fran-diaz-patch-1

Conversation

@fran-diaz

Copy link
Copy Markdown

Added variables and code to make use of banned values and preservation of option's original data attributes. In my case, i fill bannedValues array externally to filter values refered by selection on other select input. Example:

$('.selectize').selectize({
        preserveOptionsAttr: true,
        preload: true,
        onChange: function(value){
            var linked_input = this.$input.attr('data-linked-field');
            var linked_value = this.options[value]['data-linked-value'];
            var banned_values = [];
            
            if(linked_input !== undefined && linked_value !== undefined){
                $('#'+linked_input)[0].selectize['bannedValues'] = [];
                ops = $('#'+linked_input)[0].selectize.options;
                for(var opt in ops){
                    if(ops[opt]['data-linked-value'] !== linked_value){
                        banned_values.push(ops[opt]['value']);
                    }
                };
                
                $('#'+linked_input)[0].selectize['bannedValues'] = banned_values;
                $('#'+linked_input)[0].selectize.refreshOptions(false);
            }
        }
    });

Added variables and code to make use of banned values and preservation of option's original data attributes.
@joallard

joallard commented Nov 4, 2016

Copy link
Copy Markdown
Member

I'm not clear on what behavior you're fixing/enhancing here, can you explain the scenario and maybe add a test if it's important?

@github-actions

github-actions Bot commented Jan 7, 2021

Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants