Skip to content

All options are treated as user options #69

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

Open
PhiLhoSoft opened this issue Apr 29, 2015 · 4 comments
Open

All options are treated as user options #69

PhiLhoSoft opened this issue Apr 29, 2015 · 4 comments

Comments

@PhiLhoSoft
Copy link
Contributor

This wrapper takes either the value of the options attribute, or the options configuration (or the ngModel options otherwise) and adds them to Selectize via the addOption() API.

This is not a good behavior: Selectize itself treats the options configuration in a special way, using registerOption() instead, so these are base options that cannot be deleted.
Only the options really added by the user can be deleted, the others are just unselected and added back to the option list.

angular-selectize should use registerOption() too to initialize the component.

PhiLhoSoft added a commit to PhiLhoSoft/angular-selectize that referenced this issue Aug 5, 2015
- Fix machineboy2045#69
- Use registerOption instead of addOption, like Selectize does on
initialization
@PhiLhoSoft
Copy link
Contributor Author

I have made a fix for this issue, it is in my fork, but to make a clean pull request, it seems the previous pull request must be merged.
Maybe I should have made parallel branches, but somehow these fixes are more or less interdependent.

@machineboy2045
Copy link
Owner

I don't see how this distinction can be made by the wrapper. How does it know which options in $scope.options are from the user? If $scope.options becomes [] I think the wrapper should delete all options.

@PhiLhoSoft
Copy link
Contributor Author

The wrapper doesn't need to make a distinction. It adds all options in $scope.options via registerOptions, and lets Selectize to add user options via its own addOption, ie. as user options. Ie. the former are "native" options (eg. coming from the server, or hard-coded) and the latter are really the new ones entered manually.
The distinction allows to put back native options to the drop-down if removed from the selection, while user-entered options doesn't go there.
My latest pull request managed proper deletion of options.

@PhiLhoSoft
Copy link
Contributor Author

Honestly, this behavior is very annoying. I have another case where I really want to distinguish original options from typed ones!
I will see if I can rework my PR to fit current v3 version.

PhiLhoSoft added a commit to PhiLhoSoft/angular-selectize that referenced this issue Mar 3, 2016
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

No branches or pull requests

2 participants