Selected wait for Promise
See original GitHub issueGreat plugin but I am having an issue that I cannot figure how to solve. I have a dropdown that is returning a promise so when the page loads, the selected option is not getting set because the promise has not been fulfilled yet
// Route
model(params) {
return this.store.findRecord('employee', params.employee_id);
},
setupController(controller, model) {
this._super(controller, model);
controller.set('setAction', 'saveEmployee');
controller.set('providerList', this.store.findAll('provider'));
},
renderTemplate() {
this.render('admin/employeeform');
},
actions: {
saveEmployee(saveEmployee) {
saveEmployee.save().then(() => this.transitionTo('admin.employees'));
}
}
// Template
{{#power-select
selected=model.provider.content
options=providerList
onchange=(action (mut model.provider))
as |provider|}}
{{provider.name}}
{{/power-select}}
// Model
export default DS.Model.extend({
name: DS.attr('string'),
phone: DS.attr('string'),
email: DS.attr('string'),
notes: DS.attr('string'),
provider: DS.belongsTo('provider')
});
When the page loads and I click the dropdown, I can see the options. What is not working is on page load, the provider is not being selected. Thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
How to wait for a promise to finish before returning the ...
Use of setTimeout() function : In order to wait for a promise to finish before returning the variable, the function can be set...
Read more >How to Wait for Promises to Get Resolved in JavaScript
JavaScript provides a Promise.resolve() method to wait for promises by returning a promise object which is resolved by providing a given value.
Read more >How to wait for Promise.all() to complete before reaching next ...
I'm learning Node. js. I have to call an async function work() inside my Promise. all() loop and it must be completed before...
Read more >Async and Await in JavaScript, the extension to a promise.
The keyword await is used to wait for a Promise. It can only be used inside an async function. This keyword makes JavaScript...
Read more >How to use promises - Learn web development | MDN
Inside an async function, you can use the await keyword before a call to a function that returns a promise. This makes the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I’ve fixed this in just now. Check the latest beta and let me know.
Pull request