Search code examples
ember.jsember-dataember-router

Getting loading state of ember route


I have the following query params in my route:

queryParams:
  search:
    refreshModel: true

When I change search param everything changes as expected and model reloads.

The problem is: How can I check if route is still refreshing?

PS: model.isLoaded is true since page loads first time.

UPD: What I am trying to achieve: I have ObjectsController and there is a search and a table inside of it. When user submits his query, I want to hide table and show a spinner.


Solution

  • Solution that helped me.

    Ember.Route has two useful events loading and didTransition:

    actions:
       loading: ->
         @controller.set('loading', true) if @controller
       didTransition: ->
         @controller.set('loading', false) if @controller
    

    Then in tempalate:

    ..search form..
    {{#if loading}}
       show spinner
    {{else}}
       ..render collection..
    {{/if}}