简体   繁体   中英

Rivets.js attribute depends on several fields

For example I have following piece of code in EJS:

<img src="<%= model.image %>" title="Toggle: <%= model.brandName %> <%= model.productName %>" />

How can I write it in rivets.js template syntax? rv-title may help, but I should put 'Toggle:' text to my model and create a method which will concatenate it with brandName and productName. But I don't want to do as it's not model's responsibility. Any ideas on how should it work in rivets.js?

You could use a oneway binder to achieve this

http://rivetsjs.com/docs/guide/#binders

take a look at my answer at How to bind two values using rivets(like some or condittion)? for a similar situation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM