This is a migrated thread and some comments may be shown as answers.

HTML not rendering properly

1 Answer 61 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Elizabeth
Top achievements
Rank 1
Elizabeth asked on 12 Jun 2013, 01:02 PM
I'm trying to display an image on the page, I'm using javascript to write out the image tag with the source pulled from the data source. When debugging, the value that is being passed is:

<img align='Left' style='width:100px;' alt='sample alt text.' src='http://www.website.com/IMAGE-05185619.jpg>.

But what is in the page is:

&lt;img align='Left' style='width:100px;' alt='sample alt text.' src='http://www.website.com/IMAGE-05185619.jpg&gt;

So when viewing the page, I see the img tag instead of the image.

My code:

<span data-bind="text: myImgFunc"></span>

var model = JSON.parse($('#cg-jsonall').text());
 var viewModel = kendo.observable({
    model: model,
     myImgFunc: function() {
        if (this.get('model.org.org_logo'))
  {
    var img = "<img align='Left' style='width:100px;' alt='" + this.get('model.org.name') + ".' src='http://reach.hillel.org/cache/upload/" + this.get('model.university.univ_picture') + ">";
   
    return img;
  }};
kendo.bind($("span"), viewModel);

Any suggestions?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Elizabeth
Top achievements
Rank 1
answered on 13 Jun 2013, 03:23 PM
I had tried using "html" before:

<span data-bind="html: myImgFunc"></span>

and it didn't work, but it works now, something else must have been breaking that.
Tags
MVVM
Asked by
Elizabeth
Top achievements
Rank 1
Answers by
Elizabeth
Top achievements
Rank 1
Share this question
or