【发布时间】:2014-06-14 21:16:24
【问题描述】:
我有这个页面:
<template name="participant">
{{#with participant}}
<div class="participant">
<h3>{{fullname}}</h3>
<dl>
<dt>E-mail</dt>
<dd>{{email}}</dd>
<dt>Phone</dt>
<dd>{{tel}}</dd>
<dt>City</dt>
<dd>{{zip}} {{city}}</dd>
<dt>Creation time</dt>
<dd>added {{created_on}}</dd>
</dl>
{{>quickfield}}
</div>
{{/with}}
</template>
<template name="quickfield">
<input id="{{email}}" value="{{email}}" class="bound">
</template>
而且运行良好。
现在,如果我想向我的快速字段子模板添加一个参数并执行以下操作:
{{>quickfield name="foo"}}
<template name="quickfield">
<input id="{{name}}" value="{{email}}" class="bound">
</template>
数据上下文丢失(之前,this = 参与者,之后,this=Window)。 {{email}} 不再呈现。
为什么会这样,解决方法是什么?
谢谢!
【问题讨论】:
标签: meteor handlebars.js