1

I have a flow with multiple pages and when I use 'transitionTo' to go back to a route/view that has already been displayed, it's 'didInsertElement' method is not called. (it was fired the first time the view was displayed, though)

Is there an event that my view can hook into that will be called every time it is displayed?

My routes look something like this

App.Router.map(function() {
    this.resource("parent", { path: "/parent" }, function() {
        this.resource("child", { path: "/child" });
    });
});

So when I'm in the child view and call:

this.transitionTo('parent')

The parent view does not fire 'didInsertElement'.

Jeremy Gillick
  • 2,560
  • 3
  • 27
  • 35

3 Answers3

1

I found that I can use setupController in the routes to let me know each time the route is rendered. I know it's not the best solution, but so far, it is the most reliable.

Jeremy Gillick
  • 2,560
  • 3
  • 27
  • 35
0

The parent is already rendered, as the child is rendered inside of the outlet in the parent. What are you trying to do when you transition back to the parent view? There might be a better way to do what you want

Dan McClain
  • 11,780
  • 9
  • 47
  • 67
  • I'm trying to reset the original view of the view. It's a login screen which goes from showing a form to showing a progress indicator. When the person comes back to this view it needs to reset to show the login form again. I also want to keep the logic in the login view itself. So, I supposed I'm looking for an event which fires when the view is shown. – Jeremy Gillick Jun 05 '13 at 17:33
  • Any updates on this issue? I'm currently experiencing the same problem. – Vinch Aug 15 '13 at 23:31
0

If your routes are nested your templates should be too. So I would expect your template to look something like this:

<script type="text/x-handlebars" data-template-name="parent">
  <!-- Your parent View stuff -->

  {{outlet}} <!-- This is where your child gets rendered
</script>

So your parent view stuff is already inserted and stays inserted. It shouldn't be going anywhere when you transition into / out of the parent.

What exactly are you trying to do that you need the didInsertElement after transitioning back to the parent. The didInsertElement hook is really for lower level dom manipulation, like setting up jQuery plugins. If your trying to do more application logic stuff it probably belongs somewhere else.

raytiley
  • 684
  • 2
  • 7
  • 17
  • I'm trying to reset the original state of the view. It's a login screen which goes from showing a form to showing a progress indicator. When the person comes back to it, it needs to reset to show the login form again. I also want to keep the logic in the login view itself. So, I supposed I'm looking for an event which fires when the view is shown. – Jeremy Gillick Jun 06 '13 at 01:40