【发布时间】:2013-10-23 14:38:05
【问题描述】:
我试图让动态if 链接到数组中不同项的属性。
我当前的代码:
加载器
for (...) {
var index = this.App.Data.Questions.push({
...
}) - 1;
if (CompareGuids(this.App.Data.Questions[index].QuestionId, '06EF685A-629C-42A5-9394-ACDEDF4798A5')) {
this.App.PregnancyQuestionId = index;
}
模板
{^{if ~root.Data.Questions[~root.PregnancyQuestionId].Response.ResponseText == "true"}}
{{include #data tmpl="Clinical-History-QuestionWrapper-SingleQuestion"/}}
{{/if}}
它适用于初始加载,但不会更新。
注意我假设我可以使用 ~root 中的布尔属性来实现此目的,然后让 $.observable(...).oberserve(...) 更新此属性,但我更愿意直接访问。
【问题讨论】:
标签: templating jsviews