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

Refresh href in linkTo when one of the params changes #2181

Closed
wants to merge 2 commits into from

Conversation

drogus
Copy link
Contributor

@drogus drogus commented Feb 27, 2013

Currently linkTo helper is unbound when it comes to href attribute, which may be really annoying, because suddenly your pretty templates start to be full of {{#with}} helpers over every linkTo, which has the object that potentially can change.

This can be fixed rather easily by refreshing href attribute when one of the params changes.

This will of course not handle the case when the actual attribute, like an id, changes, but it will help in most cases. Most of the time you use id and most of the time id does not change.

@awkaiser
Copy link
Contributor

awkaiser commented Mar 1, 2013

Implementation method aside, 👍 on fixing unbound href in linkTo helper. If the context changes, I definitely expect that to update!

@josepjaume
Copy link
Contributor

Awesome!

@bradleypriest bradleypriest mentioned this pull request Mar 7, 2013
@drogus
Copy link
Contributor Author

drogus commented Mar 11, 2013

@wycats this is a simpler version of #2252, do you think this could be merged as a start of making linkTo better? It refreshes the href attribute when any of the params passed to linkTo changes, thus it does not need any kind of API changes. I'm just not sure about the implementation, specifically if observers on LinkView will be removed when LinkView is destroyed.

@toranb
Copy link
Contributor

toranb commented Mar 16, 2013

@ghost ghost assigned wycats Mar 20, 2013
machty added a commit to machty/ember.js that referenced this pull request Jul 2, 2013
Merge of work between @drogus and @machty.

Replaces and Closes emberjs#2181
Replaces and Closes emberjs#2252

{{linkTo}} contexts are now bound. e.g.:

    {{linkTo 'foo' pathToObj}}

will generate a linkTo that updates its
href if the resolved value of `pathToObj`
changes.

Also, if ANY of the linkTo params yield
null/undefined, including the first route name
param (if it is unquoted), href will be '#',
a new `loadingClass` class will be applied to
the linkTo element, and clicking/invoking
the loading linkTo will no-op and produce
an Ember.Logger.warn message that the linkTo
isn't loaded yet.

Note: due to overlap in loading logic and the recently
added stringified linkTo route behavior, the loading
logic is hidden behind the ENV.HELPER_PARAM_LOOKUPS
flag for now.
@machty machty closed this in #2942 Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants