In Ember, I want to create a link with an optional class. In the template, I should be able to define the binding, on which the optional class is set. The target HTML should look like this
<li class="completed"><a>Index</a></li> < completed
<li class="active"><a>Index</a></li> < active
<li class=""><a>Index</a></li> < in-active
So the active/in-active states can be achieved with the link-to
helper;
{{#link-to "index" tagName="li"}}<a>Index</a>{{/link-to}}
However, this doesn't allow me to define the optional "complete" binding. So I'm thinking about creating a subclass of LinkView
, which does provide said binding. So the next step would be to create said subclass, and implement the binding. However I don't feel like duplicating the link-to
helper, and am fine with using the view
helper. However I cannot figure out how the view
helper is supposed to work with LinkView
:
{{#view Ember.LinkView "index" }}Index{{/view}}
DEPRECATION: Global lookup of Ember.LinkView from a Handlebars template is deprecated.
Uncaught TypeError: Cannot read property 'length' of undefined
{{#view Ember.LinkView target="index" }}Index{{/view}}
DEPRECATION: Global lookup of Ember.LinkView from a Handlebars template is deprecated.
Uncaught TypeError: Cannot read property 'length' of undefined
I've been reading both the source of LinkView and link-to, but can't figure out how to proceed.
Aucun commentaire:
Enregistrer un commentaire