selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Linked / Shared list between multiple selectize

Open Ydalb opened this issue 9 years ago • 2 comments

Hello,

I would like to know if there a way to share the same "list" of option between multiple selectize, and if I select an item from a selectize A, this item is automatically removed from all the list of others selectize ?

For example, here the item "[email protected]" should not appear / be selectable in the second selectize as it's already selected in the first input. capture d ecran 2017-03-25 a 11 46 11

Ydalb avatar Mar 25 '17 10:03 Ydalb

Here is what I'm doing : I remove the last item added from others list.

    var $selectizeResponsables = $('#project_form_responsables').selectize(opts);
    var $selectizeTeamWrite    = $('#project_form_team_write').selectize(opts);
    var $selectizeTeamRead     = $('#project_form_team_read').selectize(opts);
    var selectizeResponsables  = $selectizeResponsables[0].selectize;
    var selectizeTeamWrite     = $selectizeTeamWrite[0].selectize;
    var selectizeTeamRead      = $selectizeTeamRead[0].selectize;

    // Prevent from adding same item on others fields
    selectizeResponsables.on('item_add', function(value, $item) {
        selectizeTeamWrite.removeItem(value);
        selectizeTeamRead.removeItem(value);
    });
    selectizeTeamWrite.on('item_add', function(value, $item) {
        selectizeResponsables.removeItem(value);
        selectizeTeamRead.removeItem(value);
    });
    selectizeTeamRead.on('item_add', function(value, $item) {
        selectizeResponsables.removeItem(value);
        selectizeTeamWrite.removeItem(value);
    });

Ydalb avatar Mar 25 '17 12:03 Ydalb

closing stale issues older than one year. If this issue was closed in error please message the maintainers. All issues must include a proper title, description, and examples.

risadams avatar Nov 12 '20 15:11 risadams