question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selected wait for Promise

See original GitHub issue

Great 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:closed
  • Created 7 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
cibernoxcommented, Apr 1, 2016

I think I’ve fixed this in just now. Check the latest beta and let me know.

0reactions
cibernoxcommented, Mar 29, 2016

Pull request

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found