Pergunta

Starting out in this ember stuff and I cant seem to the {{link-to}} helper in handlebars working as I expect when looping though {{each}}.

{{#each}}
  <h1>{{name}}</h1>
  <p>{{description}}</p>
  <p>{{#link-to 'cocktail' this}}more...{{/link-to}}
{{/each}}

I have a nav bar (home, cocktails, about) and an outlet below it to render templates.

For the "/cocktails" route all cocktails are listed using {{each}} looping through the array in my model. And for each cocktail is a link to "/cocktails/:cocktail_id" which should display a single cocktail only.

Going to each of the routes directly behaves as expected but using a link-to from the cocktails list page renders the new template without removing the cocktail list.

http://jsfiddle.net/tobias_g/Lxebv/

Cant tell whats missing/going on here any help appreciated.

Foi útil?

Solução 2

This is due to the lack of closing paragraph tag after the {{link-to}} causing the new template to render but the previous template to remain too.

as @zaius suggested Ive added an issue to handlebars issue tracker for those who are interested to see what happens to this issue.

https://github.com/wycats/handlebars.js/issues/738

Outras dicas

While you are missing the closing tag, this still looks like a bug to me. An unclosed <p> tag is valid html. It also does it even with a self closing <p />. I would file a bug on handlebars' issue tracker.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top