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

wants to merge 2 commits into


None yet

5 participants

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 commented Mar 1, 2013

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



@bradleypriest bradleypriest referenced this pull request Mar 7, 2013

linkTo don't bind #2231

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.

@wycats wycats was assigned Mar 20, 2013
@machty machty added a commit to machty/ember.js that referenced this pull request Jul 2, 2013
@machty @machty machty + machty {{linkTo}} bound contexts, loading class
Merge of work between @drogus and @machty.

Replaces and Closes #2181
Replaces and Closes #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`

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