Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

link-to helper will run linked route controller init hook when rendered #15973

Closed
moveniumville opened this issue Dec 13, 2017 · 7 comments
Closed
Labels

Comments

@moveniumville
Copy link

When you put link-to helper in your code, it will run linked routes init-hook in controller when rendering helper.

{{#link-to "page"}}Link to other route{{/link-to}} will run init-hook in "page"-routes controller

I have provided a simple example project where you can see the error
https://github.com/moveniumville/ember_link-to_init

Not working in 2.16 and 2.17 at least

@marialomidze
Copy link

I am running into the same issue with ember-cli 2.16

@locks
Copy link
Contributor

locks commented Jan 5, 2018

I believe this is because you need to initialize the controller to check for default values for query params, in order to know what to display. Trying to confirm this.

@joshwbrick
Copy link

joshwbrick commented Mar 16, 2018

Running into this issue as well. Seems like this is an issue with 3.0+. Just started noticing it when I upgraded from 2.x

@rwjblue
Copy link
Member

rwjblue commented Apr 21, 2018

As @locks mentioned, the target controller is instantiated so that we can properly handle query params. This isn't a bug per-se, but a limitation of the current {{link-to implementation. Changing it to not instantiate controllers would almost certainly be a breaking change.

@konradjurk
Copy link

With Ember 2.13 and before the init hook of the target controller was not executed. It only started with Ember 2.14 if that helps. If this is indeed expected behavior now it should be documented.

@Alonski
Copy link
Member

Alonski commented Sep 4, 2018

@konradjurk Created this Twiddle that demonstrates this:
https://ember-twiddle.com/9491a0c301b8d73c50b6290feff7d9d2

Go to parent route and change between versions 2.12 and 2.18 for example to see the difference in functionality.

@locks locks added the wontfix label Mar 26, 2019
@locks
Copy link
Contributor

locks commented Mar 26, 2019

Closing this issue due to inactivity and due to the fact that the controller being instantiated is a side-effect of needing to check the default values of query params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants