mardi 24 mars 2015

Render Image from REST API Call



Here's the var from the function:



var aoTiles = "<div class='col-md-4 tile'><div class='tileImg' style='background: url(" + [value=this.Image_x0020_Thumbnail_.Url] + ") no-repeat 0 0;'><span class='openRotator'></span></div><div class='tileTitle'>" + this.Title + "</div><div class='tilePrice'>" + this.Product_x0020_Price.toFixed(2) + "</div></div>";


Instead of rendering the image, I get nothing.


If I do something simple like this:



var aoTiles = "<div class='col-md-4 tile'><div class='tileImg'>" + this.Image_x0020_Thumbnail_.Url + "</div><div class='tileTitle'>" + this.Title + "</div><div class='tilePrice'>" + this.Product_x0020_Price.toFixed(2) + "</div></div>";


If you need the full function:



function addOnsTiles(){
$.ajax({
async: false,
url: "/_api/lists/getByTitle('Products')/items",
type: "GET",
headers: { "Content-Type": "application/json;odata=verbose", "Accept": "application/json;odata=verbose" },
success: function (data) {
$.each(data.d.results, function () {
var aoTiles = "<div class='col-md-4 tile'><div class='tileImg'>" + this.Image_x0020_Thumbnail_.Url + "</div><div class='tileTitle'>" + this.Title + "</div><div class='tilePrice'>" + this.Product_x0020_Price.toFixed(2) + "</div></div>";
$('.aoTilesTopWrapper').append(aoTiles);
});
},
error: function (data) {
alert(data.statusText);
}
});

return true;
}


It gives me the image URL but still no image.


Why is it not rendering?








0 commentaires:

Enregistrer un commentaire