javascript - Why does $.each show only one of my Mustache templates? -
i'm using $.get
inside $.each
call external mustache template use on each photo object in array.
here code:
$.when.apply($, requests).then(function(dataone, datatwo) { $.each(dataone, function(idx, obj) { $.get("mytemplate.mst", function(template) { var rendered = mustache.render(template, obj); $photoelem.html(rendered); }); }); });
my problem once refresh screen, 1 of array objects shows up. i'm aware of {{#item}}
iterate through array i'm using $.each
specific reason.
can tell me i'm doing wrong?
try one
$.when.apply($, requests).then(function(dataone, datatwo) { $.get("mytemplate.mst", function(template) { $.each(dataone, function(idx, obj) { var rendered = mustache.render(template, obj); $photoelem.append(rendered); }); }); });
suppose problem causes replace content of $photoelem ( using .html() ) instead of appending each new item
i replace .html() .append(
and change code read template once ( @andy )
Comments
Post a Comment