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

Dynamic update of options does not appear to work in Select2 #61

Closed
cthrax opened this issue Jul 29, 2014 · 2 comments
Closed

Dynamic update of options does not appear to work in Select2 #61

cthrax opened this issue Jul 29, 2014 · 2 comments

Comments

@cthrax
Copy link
Contributor

cthrax commented Jul 29, 2014

I am unable to see the options reflect modifications to a list in the controller. A plnkr demonstrating the issue can be seen here

http://plnkr.co/edit/OIsfV0hOJfdj1dswUzgm?p=preview

I also present a workaround, but I had to hack around the fact that I wasn't using an $http promise. Might be a thought for a future enhancement to use the standard promise interface, rather than success.

@johnculviner
Copy link
Member

Good catch, I hadn't used it with normal promises before.

Perhaps it should use q.all instead?

Here is the line:

.success(function (data) {

Feel free to send me a PR that keeps the old way working but makes your way work as well if that works? Otherwise I'l try to get something out there later this week. Thanks!

@cthrax
Copy link
Contributor Author

cthrax commented Jul 31, 2014

I couldn't add any really substantive unit tests because select2 doesn't expose a method of getting the data that it is bound to. I do have some isolated tests that verify promise functionality works as expected from http. Namely that success goes to the success handler of then and failure does not. So just changing success to then was all that was necessary.

Additionally, I added the ability to return an array from this, which is really the use case that I have. It's a little bit of guessing, so whether you want to document the feature or not, that's up to you.

Cheers.

@cthrax cthrax closed this as completed Jul 31, 2014
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