I'm using the text plugin with requireJS in order to load some html into the page. I've defined a modules that is responsible for this:
define(['jquery', 'text!/path/to/template/template_name.html'], function($, rciTpl){
Inside the module I have a method that, after receiving data from an ajax call ads items to the DOM:
var buffer = $.map(data, function(d, i){
//clone the template;
var tpl = template.clone();
//set the url
tpl.find('a.lt, a.la').attr('href', d.url);
//set the title
tpl.find('a.lt').text(d.title);
//return the raw node
return(tpl.get());
});
$('#myContainer').append(buffer);
Everything works ok so far. Problem appears when I want to add an image dynamically to my template. Something like this:
tpl.find('img').attr('src', 'item_img_path.svg');
The error that I get in the browser's console is: "Resource interpreted as Image but transferred with MIME type text/html", which makes sense, but I don't know how to get passed it.
I am also opened to different approaches in achieving my task.
Thanks.