Knockout.js dynamic links do not click through
I am working on a new project that is using knockout js. I have setup a
small table that displays images and info entered into a form that
populates an observable array. I have the images wrapped with an anchor
(link) tag and I am feeding the in the href through the KO data-bind. See
below.
<a data-bind="attr: {href: imgUrl}" target="_blank"><img class="imgThumb"
data-bind="attr: {src: imgUrl}"/></a>
All of this displays as expected, however none of the links will actually
click through to the image location.
An array entry looks like this:
col1: 'Bert', col2: 'Muppet', col3: 'Sesame Street', imgUrl:
'http://images3.wikia.nocookie.net/__cb20101210195428/muppet/images/4/40/Bert1970s.jpg'
The rendered HTML looks like this:
<a data-bind="attr: {href: imgUrl}}" target="_blank"
href="http://images3.wikia.nocookie.net/__cb20101210195428/muppet/images/4/40/Bert1970s.jpg"><img
class="imgThumb" data-bind="attr: {src: imgUrl}"
src="http://images3.wikia.nocookie.net/__cb20101210195428/muppet/images/4/40/Bert1970s.jpg"></a>
Once again, none of my links work, they will not click through to the
image location as I expect them to. Can anyone help me here and point out
what I am missing. Also, of note, I have tried adding a click: function(){
return true; } as well, and that didn't help either. Thanks in advance.
No comments:
Post a Comment