Loading event when saving form


#1

I was reading up on https://guides.emberjs.com/v3.1.0/routing/loading-and-error-substates/#toc_the-code-loading-code-event And I am wonder if when I submit a form that does not transition, can I call this loading event or do I need to build my own solution?


#2

@jrock2004 What does you form do? I don’t think you can manually move to the loading state if you aren’t triggering any of these hooks: beforeModel / model / afterModel.

For these kind of scenarios I would recommend using Ember concurrency. You can handle loading states really easy:

Example:

<button onclick={{perform submitTask}} class={{if submitTask.isRunning 'disabled'}} >
  {{#if submitTask.isRunning}}
    Saving...
  {{else}}
    Save
  {{/if}}
</button>