【发布时间】:2014-07-25 12:30:21
【问题描述】:
我有一个渲染良好的页面,每当我刷新页面时,它都会显示异常 如下所示
Exception from Deps recompute function: TypeError: Cannot read property 'option1' of undefined
at Object.Template.display_poll.helpers.product_title1 (http://localhost:3000/client/xxx.js?9b4f281e748352d5500dbda34a33f155fc8cc293:838:49)
at apply (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:276:24)
at invoke (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:301:12)
at http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:365:30
at Object.Spark.labelBranch (http://localhost:3000/packages/spark.js?742c715b73fac26c16ad433118b87045bc5658ff:1170:14)
at branch (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:355:20)
at http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:364:18
at Array.forEach (native)
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:11)
at template (http://localhost:3000/packages/handlebars.js?c2b75d49875b4cfcc7544447aad117fd81fccf3b:358:7)
导致异常的行是
product_title1:function() {
var title1=Polls_Coll.findOne({_id:this._id}).option1[0].pd;
return title1;
}
这是我的模板
<template name="display_poll">
<!-- displaying poll question -->
{{uniqueid}}
<p class="label-design table-pop-more" name="{{unique_id}}">
<img src="/images/polls.jpg">{{question}}</p>
<div class="table-pop-more">
<div class="poll-options" id="menuitems">
<ul>
<!-- product thumbnails -->
<li><input type="text" class="pad-top" id="{{id_op1}}"
value="{{product_title1}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op2}}"
value="{{product_title2}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op3}}"
value="{{product_title3}}" readonly/><br></li>
<li><input type="text" class="pad-top" id="{{id_op4}}"
value="{{product_title4}}" readonly/><br></li>
</ul>
</div>
</div>
</template>
帮我解决这个问题。 如果您需要任何其他信息,我会提供。
【问题讨论】: