I am using jquery getto load html into my content div. The HTML that I am loading contains some images, and I find that my custom height calculation that I do in javascript does not work too well because the images are fully loaded upon return loadHTML.
var loadHTML = function(){
return $.get("javascripts/templates/" + templateType + ".html", function(text) {
$("#content").html(text);
});
};
Is there any way to return only from loadHTMLafter downloading all the images? I tried to call and return load, but this does not work.
var loadHTML = function() {
return $.get("javascripts/templates/" + templateType + ".html", function(text) {
var content = $("#content").html(text);
return $('img', content).load();
})
};
In addition, I use Q promises in other parts of my application, so that I can fix my problem using this.
t loadHTML.then(loadImages).then(doOtherStuff);
source
share