我正在遍历数组控制器以显示项目-在此视图中,我尝试使用当前地址的上下文执行自定义 Handlebar 助手-但是在我的助手中,该对象未定义。
看法:
{{#each temporaryUser.addresses}}
{{#view App.AddressView addressBinding="this"}}
{{addressActions view.address}}
{{{view.address.display}}}
<a {{action deleteAddress target="view"}} class="delete">Delete</a>
{{/view}}
{{/each}}
Handlebars.registerHelper('addressActions', function (address) {
var display = '<div class="actions">';
if (address.current && address.permanent) {
display += '<p>This is my current residential, and permanent address:</p>';
}
else if (address.current && !address.permanent) {
display += '<p>This is my current residential address:</p>';
display += '<a href="#">Make permanent residential address</a>';
}
else if (!address.current && address.permanent) {
display += '<p>This is my permanent address:</p>';
display += '<a href="#">Make current residential address</a>';
}
else {
display += '<a href="#">Make current residential address</a><br/>';
display += '<a href="#">Make permanent residential address</a>';
}
display += '</div>';
return new Handlebars.SafeString(display);
});