Posted on

Onclick bind image using knockout js

I want to show image from allDoorColorStandard.

HTML:

Onclick “color-data” div , i want to update image.
In alert i’m getting image URL, now need to bind in image tag.

<div data-bind=”foreach: { data: doorColorList, as: ‘doorStyleType’ }”>

<img data-bind=”attr: {src: image,alt:name}” width=”85″ height=”85″>

<div data-bind=”foreach: { data: Object.values(doorStyleType.colors.standard) , as: ‘allDoorColorStandard’ }”>
<div class=”color-data” data-bind=”click: $parents[1].selectColor”>

<span class=”style-name” data-bind=”text: allDoorColorStandard.color_name”></span>
</div>
</div>

</div>

JS:

selectColor: function (styleColor,color) {
alert(‘kkkk’+styleColor.mapping_image);
self.mappingImage(styleColor.mapping_image);
},

Any help will be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *