Añadir clase a ember link-to


Intento construir un enlace a una ruta anidada y quiero agregar una clase a este enlace (para twitter bootstrap)

El resultado debería ser algo como esto:

< a href="/#/rents/42" class="btn btn-primary btn-small">do something< /a>

Primer intento:

{{#link-to "rent" rent}}

Me da un enlace al ressource pero no puedo especificar una clase (css). En los documentos veo que solo se puede especificar el atributo title

Segundo intento:

< a href="/#/rents/{{rend.id}}" class="btn btn-primary btn-small">do something< /a>

También es una mala idea, porque Ember agregará sus etiquetas auxiliares [para actualizaciones automáticas] en el href.

Entonces qué ¿puedo hacerlo?

 54
Author: Patsy Issa, 2013-01-28

3 answers

Uso:

{{#link-to 'rent' rent class='btn btn-primary btn-small'}}Go to rent{{/link-to}}

Como link-to es un ayudante de vista.

 107
Author: sly7_7,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-06 14:12:09

Puede agregar clases muy bien en los ayudantes {{#linkTo}}, solo necesita recordar no confundir a ember.

Ember puede pensar que tu clase es la routeName de la params, incluyo la clase después de params y routeName y funciona bien.

{{#linkTo 'dashboard.screenshots' value.model class='thumbnail'}}
   ........
{{/linkTo}}

Produce

<a id="ember507" class="ember-view thumbnail" href="#/project-2/member-1/task-2/screenshot-30">
   .........
</a>
 10
Author: iConnor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-13 20:46:12

Si desea construir manualmente algo a partir de variables, existe {{unbound}} helper en ember.js.

En su caso el código se verá como:

<a href="/#/rents/{{unbound rend.id}}" class="btn btn-primary btn-small">
   do something
</a>
 1
Author: sashasimkin,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-24 19:05:39