Call html() function on $.tmpl function's return object
Plunker code is here.
I am trying to get the html content out of a jquery template and its data. Is n't the return type of tmpl
a jquery wrapped object?
This code,
$.each($('#movieTemplate').tmpl(movies), function(idx,elt){
tmplContent = tmplContent + elt.html()
});
throws error as
elt.html is not a function
Note: I can make it work with an alternate way as shown in plunker
But i am trying to figure out the object type of $.tmpl's return value?
Answers 1
Use
document.createElement
to create an html container and instead of concatenating the html as string, append the htmlOr if you still want to use it as string, you can do it this way