HTML not rendering properly

2 posts, 1 answers
  1. Answer
    Elizabeth
    Elizabeth avatar
    11 posts
    Member since:
    Mar 2005

    Posted 12 Jun 2013 Link to this post

    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.
  2. Elizabeth
    Elizabeth avatar
    11 posts
    Member since:
    Mar 2005

    Posted 13 Jun 2013 Link to this post

    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.
Back to Top