Skip to content

ui-select not updating after asyncCallback #43

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
eburi opened this issue Sep 16, 2015 · 4 comments
Closed

ui-select not updating after asyncCallback #43

eburi opened this issue Sep 16, 2015 · 4 comments

Comments

@eburi
Copy link

eburi commented Sep 16, 2015

I'm trying to integrate ASFDS into my project with ui-select for autocomplete and the asyncCallback to actually get the data from the server.

I noticed, that the asyncCallback gets called and the results I return, show up in the dropdown. But the filed already has a value and the ui-select will not switch to this value, once that value is in the titleMap (after asyncCallback return the results) instead it always displays the placeholder.

Is there something I can call on the formOptions passed into the asyncCallback?

The problem is, that I don't have an initial titleMap. The ui-select will be populated with values from a REST-Endpoint and initially I can only load the value that field already points to. But when I return that (name,value)-pair form asyncCallback, I get the console message: "asyncCallback items [Object, Object]", where the current value of the field is present, but the ui-select does not change from the placeholder to that value.

I tried this before with starpselect and it was working there. But with the strapselect, I'm missing the possibility for the user to type in something and then lookup values based on this input.

Any ideas?

@nicklasb
Copy link
Member

Well, that you do not have an initial titleMap is sort of the point with ASFDS, so that in itself is not a problem.
Not sure if I have understood you correctly, but async callback should not return the items, but a promise.
If you want to work synchronously, please use "callback" instead.
See the app.js in the example for how to use asyncCallback:
https://github.com/OptimalBPM/angular-schema-form-dynamic-select/blob/master/app.js#L64

$http.get(options.urlOrWhateverOptionIWant) returns the promise, not the array of data.

@eburi
Copy link
Author

eburi commented Sep 17, 2015

The asyncCallback with promises is implemented properly. The items returned are inserted into the dropdown. But $scope.select_model.selected should be set after the dropdown-data changed.

I found a fix and I'll do a PR

@nicklasb
Copy link
Member

Ok, great! The UI-select implementation is a complicated and quite hard to improve upon due to how ui-select works, so all PR:s in that regards are very appreciated.

@nicklasb
Copy link
Member

Thanks @eburi for your help on this one. I didn't even properly understand what the problem was until I saw you PR. :-)

This means that this issue is resolved in the 0.12.3-release.

Closing and thanks again!

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