Answer the question
In order to leave comments, you need to log in
Underscore doesn't work correctly, what should I do?
I use a template engine, I send an ajax request, what is needed is returned in the network tab, but underscore inserts a lot of elements, although they returned, let's say only 2. The same template code used to work on another site, I just copied it and pasted it, of course, having corrected.
ajax code
$(".sended-param").click(function(){
var template = $("#products").html();
$(this).find("input[type=radio]").prop('checked', true);
$.ajax({
type: "post",
url: "/filter",
data: $(".filter form").serialize(),
success: function(result) {
$(".products").html(_.template(template,{ result:result }));
}
});
});
<script type="foo/bar" id="products">
<% _.each(result,function(item,key,list){ %>
<li>BLa</li>
<% }); %>
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question