Skip to content
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

Selectize.ClearOptions() doesn't work when loading data dynamically. #94

Closed
karan-kang opened this issue Sep 3, 2015 · 7 comments
Closed

Comments

@karan-kang
Copy link

Since angular-selectize doesn't listen for selectize clear event, the options in directive memory become stale if selectize.clearOptions() is called.

Due to this, new data keeps getting appended to the existing options.

@karan-kang
Copy link
Author

Pull request #95 should fix this issue

karan-kang pushed a commit to karan-kang/angular-selectize that referenced this issue Sep 4, 2015
@dlaviati
Copy link

dlaviati commented Sep 7, 2015

Same issue here and the suggested fix works perfectly for me.

@machineboy2045
Copy link
Owner

Hmm.. my thought so far is that users should be using angular to manipulate their options. They shouldn't be calling selectize.clearOptions(). They should use $scope.options = []. So the directive shouldn't need to listen for that event.

@karan-kang
Copy link
Author

If the user is loading data from remote source, they don't have direct access to $scope.options. Also, the original library has the functionality of clearing options, I think angular-selectize should too.

@machineboy2045
Copy link
Owner

Again, if the data is a remote source, it should be loaded in an Angular controller, and assigned to the Angular model.

@karan-kang
Copy link
Author

The data loading is not the problem here, the problem is once the loaded data is cleared, the value of $scope.options variable in this directive doesn't match the source data inside the selectize library.

@machineboy2045
Copy link
Owner

Since this is an Angular directive, the expectation is that the user will rely on Angular for loading options.
$http.get(remoteURL, function(data){ $scope.options = data; })

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

3 participants