How to render an <IMG> HTML tag with variable attributes inside a Knockout template?

image
html
data-bind
knockout
(Dmitry Fedyuk) #1

The attr binding provides a generic way to set the value of any attribute for the associated DOM element.

http://knockoutjs.com/documentation/attr-binding.html

Knockout’s declarative binding system provides a concise and powerful way to link data to the UI.

http://knockoutjs.com/documentation/binding-syntax.html

Example 1

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Braintree/view/frontend/web/template/payment/cc-form.html#L89-L94

Example 2

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Captcha/view/frontend/web/template/checkout/captcha.html#L16-L21

Example 3

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Catalog/view/frontend/web/template/product/image.html#L7-L7

Example 4

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/Checkout/view/frontend/web/template/summary/item/details/thumbnail.html#L10-L11

Example 5

https://github.com/magento/magento2/blob/8fd3e8/app/code/Magento/ConfigurableProduct/view/adminhtml/web/template/variations/steps/summary-grid.html#L33-L33

0 Likes