mardi 9 juin 2015

Dynamically change link-to routeName

tl;dr: How to fix this: http://ift.tt/1KmfkP8 ?

I need to dynamically change routeName of link-to helper. The motivation here is to create back button in bread-crumb navigation.

Problem arrises when my application transitions from route having one dynamic segment to route with multiple dynamic segments. This results in multiple #if statements, because #link-to cannot accept variable number of dynamic segments. SO example.

I can fix that by adding multiple #if statements. Not nice, but in theory it works. Problem is that #link-to routeName property is recalculated before #if statement can apply and wipe out that link from displaying. So Ember crashes on:

Uncaught Error: You didn't provide enough string/numeric parameters 
to satisfy all of the dynamic segments for route bar

Above example is not my complex back-button code. Just stripped example.

Aucun commentaire:

Enregistrer un commentaire