【发布时间】:2016-05-16 10:10:47
【问题描述】:
我目前正在恢复从 HTTP CALL 格式化的 JSON。 该函数使用表单模板提供的参数启动,并通过提交事件将参数推送到变量上。
我的函数 getusershttp 能够返回一些我可以通过 console.log(results.content); 看到的结果:
"results" : [
{
"name" : {
"first" : "Billy",
"last" : "McKornic"
},
"id" : "a1c3fd06c71ccc50998baa02074976b4d639e4cf",
"situation" : "free",
},
{
"name" : {
"first" : "Dough",
"last" : "Wallas"
},
"id" : "5694c02beaf20d2d4b5747668b82264af8547e33",
"situation" : "occuped",
}
],
"status" : "OK"
}
我想将每个结果放在我的文章模板中:
<template name="articles">
{{#each results}}
<header>
<p>{{name.first}} {{name.last}}</p>
<p>{{id}}</p>
<p>{{situation}}</p>
</header>
{{/each}}
</template>
为了提供每个结果数据,我必须创建什么模板事件和函数? 目前我有:
Template.articles.helpers({
results : function() {
return Meteor.call("getusershttp",FormParamX,FormParamY);
}
});
但是我在页面加载时遇到了 java 错误,因为我的表单没有提交并且 FormParamX 和 FormParamY 没有填充。 如何强制我的模板(事件和函数)等待我的表单提交才能开始提供结果?
谢谢!
【问题讨论】:
标签: java forms templates meteor dynamic