I am trying to the following but it's not working:
<!-- ko foreach: _Poi_Images_List -->
<img data-bind='attr: {alt: "images/"+ PATH }' />
<!-- /ko -->
when I remove the "images/"+ part it works, but as soon as I add it. it messes up with javascript and not the actual PATH i want, and it bees like this:
<span data-bind="attr: {alt: "images/"+ PATH }" alt="images/Poi/function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}"></span>
any ideas? I have already checked this reference for the concatenation part and I basically did the same: Concatenate Strings in Knockout
thanks
I am trying to the following but it's not working:
<!-- ko foreach: _Poi_Images_List -->
<img data-bind='attr: {alt: "images/"+ PATH }' />
<!-- /ko -->
when I remove the "images/"+ part it works, but as soon as I add it. it messes up with javascript and not the actual PATH i want, and it bees like this:
<span data-bind="attr: {alt: "images/"+ PATH }" alt="images/Poi/function c(){if(0<arguments.length){if(!c.equalityComparer||!c.equalityComparer(d,arguments[0]))c.I(),d=arguments[0],c.H();return this}a.U.La(c);return d}"></span>
any ideas? I have already checked this reference for the concatenation part and I basically did the same: Concatenate Strings in Knockout
thanks
Share Improve this question edited May 23, 2017 at 12:23 CommunityBot 11 silver badge asked Nov 21, 2012 at 15:59 roy naufalroy naufal 3991 gold badge8 silver badges21 bronze badges1 Answer
Reset to default 6You have to unwrap observable when use it in expression. Change your code to this:
<!-- ko foreach: _Poi_Images_List -->
<img data-bind='attr: {alt: "images/"+ PATH() }' />
<!-- /ko -->