node.js'yi kullanarak bir uygulama yapıyorum ve sunucu ve istemci tarafı için şablonlar için gidonu kullanıyorum. Ancak, bir nesne üzerinde yinelenen sorun yaşıyorum.Nesneler üzerinde yineleme yapmayan jp'ler
Benim .js dosyası::
$(function() {
var theTemplateScript = $("#update_address_distributor_template").html();
context.city = 'london';
var theTemplate = Handlebars.compile(theTemplateScript);
var theCompiledHtml = theTemplate(context);
$('.update_address_distributor_template_placeholder').html(theCompiledHtml);
});
Benim html dosyası:
<script id="update_address_distributor_template" type="text/x-handlebars-template">
<form class="form-horizontal" role="form" id="update_distributor_form">
\{{city}} //correctly prints out london
\{{address_distributors.length}} //returns 2, so i know the object exists
{{#each address_distributors}}
\{{name}} //does not print anything
{{/each}}
</form>
</script>
Benim bağlam nesnesi:
{
address_distributors: {
[
{
name: 'nike',
id: '1'
},
{
name: 'yokohama',
id: '4'
}
]
},
city: 'london'
}
şey yazmaz {{#each ../address_distributors}} ... {{/each}}
Benim İşte benim kod. Html sayfasında \\{{address_distributors.length}}
baskıları 2 olduğundan, addres_distributors
nesnesinin çıkışını biliyorum. Ayrıca, gidon şablonumun düzgün bir şekilde kurulduğunu test etmek için context.city = 'london';
'u yazdırıp basmadığını görmek için ayarladım. Bu yüzden, sorunun nesne ile bir ilgisi olduğunu biliyorum ...
Birisi yardımcı olabilir mi?
Şimdiden teşekkürler!
''/'tuhaf bir şey değil mi? – Cohars
onu çıkardım; Hala çalışmıyor .. –
İsim/Nerede tanımlanmış? –