steakchaser
steakchaser

Reputation: 5239

Customize loading template for non-nested ember route

Using ember: 1.7.0

I'm trying to used different loading templates depending on the route that is being transitioned to in my app. None of my routes are nested (i.e. contained within a resource). I've only been able to get ember to serve up the application loading template. Is there a way to override this behavior in the case of non-nested routes?

Here's a jsbin illustration the problem:

  1. Two loading templates are defined loading and top-loading.
  2. When loaded up the app transitions to the top route.
  3. I was hoping this would trigger the top-loading template, but instead it triggers the loading template.

http://emberjs.jsbin.com/pamego/1/

Thanks in advance for any assistance!

Upvotes: 1

Views: 84

Answers (2)

Mitch
Mitch

Reputation: 1555

I'm going to do that thing where I question a premise of your question:

If your routes aren't nested then there should be no harm in treating them as resources. Routes only have special behavior when they are nested (they don't reset their namespace).

Conceptually, changing this route to a resource works. The "loading" state is really an enhancement or a special form of "top". When something has multiple states like this, modeling it as a resource makes sense. With all that preamble, I propose this:

http://jsbin.com/javihuceqo/1/edit?html,js,output

Upvotes: 2

Steve H.
Steve H.

Reputation: 6947

The problem is that your route is only nested one level deep, so the application-level loading substate is active. If you had a Route that was 2 levels down, "FooBar", for example, then trying to load the FooBarRoute model would cause the foo/loading template to be displayed.

Please see this jsbin for an example.

Upvotes: 2

Related Questions