mardi 27 octobre 2015

Ember.js Route: How to avoid infinite loop when refreshing parent route from child setupController

I have two nested routes, projects and projects/project. Whenever I open a project, I would like the projects route to be refreshed.

What I am doing know is to call a controller function during the setupController hook (that will end up calling refresh in the projects route). Something like this:

  // project route
  setupController: function(controller, model) {
    this.controllerFor('projects').send('search');
    controller.set('model', model)
  }

  // projects controller
  actions: {
    search: function() {
      // do other things
      this.send('refreshModel');

    }
  }

  // projects route
  actions: {
    refreshModel: function() {
      this.refresh();
    }
  }

The problem is that, when the refresh function is called, it not only refreshes the current route, but also all the children routes, meaning that this setupController hook will be executed again, creating this infinite loop.

Is there a way to make Ember refresh just the current route, ignoring its children?

Thank you.




Aucun commentaire:

Enregistrer un commentaire