Skip to content

clearOptions: Don't remove already selected items #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

andrey-lizunov
Copy link
Contributor

Closed #1079

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 72a065d on andrey-lizunov:master into * on selectize:master*.

@joallard
Copy link
Member

Can you explain your PR? I wasn't able to understand the issue ref'd.

@andrey-lizunov
Copy link
Contributor Author

andrey-lizunov commented Jun 28, 2016

@joallard I found that selectize accumulates options from previous searches. I upload new list of options remotely from my server and the number of selected items not limited. In this case after several searches in dropdown I have a lot of options connected with old queries which I don't need.
I tryed to call clearOptions before upload new list of options, but clearOptions calls clear function inside and this removes all items which was chosen before.
The problem that I want to be able to clear just list of options without removing already selected items. I talking about multiple selects.

This PR change this behavior, now the list of selected items stay unchanged, but list of options for select is cleared.

delete options[key];
}
});
self.options = self.sifter.items = options;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not the same as:

$.each(self.options, function(key, value) {
  if(self.items.indexOf(key) == -1) {
    delete self.options[key];
  }
});
self.sifter.items = self.options;

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brookjordan I confirm, your code works fine.

@mtebele
Copy link

mtebele commented Nov 9, 2016

Any workaround for this?

@colalex
Copy link

colalex commented Feb 15, 2017

Is this still open?
I have the problem only on Android (other system work fine even with chrome) when I want to delete a selected item.

@andrey-lizunov
Copy link
Contributor Author

andrey-lizunov commented Feb 15, 2017

@colalex This issue is not about deleting a selected item.
It's about clearing (generate new list) options when you already have selected options and your list of options are dynamic (ajax from server).

@ravins
Copy link

ravins commented Feb 21, 2017

still open ?

@legshooter
Copy link

@joallard Any chance you can merge this? A couple of these really small fixes for impactful UX issues are hanging around, and we could really use your help.

joallard added a commit that referenced this pull request May 2, 2018
@joallard joallard closed this May 2, 2018
@joallard
Copy link
Member

joallard commented May 2, 2018

Had to rebase that one

michael-maltsev pushed a commit to michael-maltsev/selectize.js that referenced this pull request Aug 28, 2018
@kstratis
Copy link

kstratis commented Feb 17, 2021

2021 and this is still an issue... unbelievable...

@risadams
Copy link
Contributor

2021 and this is still an issue... unbelievable...

Would you believe that a PR closed two years ago might not be quite relevant to today's environment? Feel free to open a new issue with a working example, or submit your own PR with the changes you wish to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to dynamically update options on type