How to hide blocks for a route when going to a sub-route

Asked

Viewed 72 times

0

I am using Ember 2 and things are complicated for those who have no Ember experience. I have the following routes

consultas\

consultas\reserva

And on my router.js is like this

this.route('consultas', function() {
    this.route('reservas');
}

The query template has some information I want to hide when going to the booking template. How can I do this in Ember 2.0 or how do I know which route I am by calling my helper to do this?

I asked the same question on SOEN. If you want to follow the answers.

1 answer

3


You could have the following template structure:

Hbs consultations.
queries/index.Hbs
consultations/reservations.Hbs

In the Hbs consultations. there would be a {{outlet}}.
When you were on route queries, Ember would render the queries/index.Hbs in that {{outlet}}.
When you were on route queries/reservations, Ember would render the consultations/reservations.Hbs in the {{outlet}}.

That way, whatever was in the index Hbs. would be shown on the parent route, but not on the sub-route. Simply put what you want to hide on the index Hbs..

However, this would only work well for contiguous blocks of code. If the information you want to hide is too scattered in the template, you might want to use a variable in the query route to define when it should be shown, and use willTransition to detect when entering the daughter route.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.