【发布时间】:2012-08-08 00:19:41
【问题描述】:
这个非常简单的应用程序无法运行。我的列表没有显示。为什么?我一定错过了有关 Meteor 工作原理的重要信息。
recipes.html
<body>
<h3>Recipes</h3>
{{> recipes}}
</body>
<template name="recipes">
<ul>
{{#each recipes}}
<li>{{name}}</li>
{{/each}}
</ul>
</template>
recipes.coffee
Recipes = new Meteor.Collection("recipes")
if Meteor.is_client
Meteor.startup ->
Meteor.autosubscribe(->
Meteor.subscribe('recipes')
)
# THIS IS NOT WORKING
Template.recipes.recipes ->
return Recipes.find()
if Meteor.is_server
Meteor.startup ->
if Recipes.find().count() == 0
data = [
name: "Chocolate Chip Cookies"
,
name: "Spring Rolls"
]
for item in data
Recipes.insert(item)
Meteor.publish('recipes', ->
return Recipes.find()
)
错误
Uncaught TypeError: Object function (data) {
var getHtml = function() {
return raw_func(data, {
helpers: partial,
partials: Meteor._partials
});
};
var react_data = { events: (name ? Template[name].events : {}),
event_data: data,
template_name: name };
return Meteor.ui.chunk(getHtml, react_data);
} has no method 'recipes'
我已经尝试过使用自动发布和不使用自动发布。我在这里不明白什么?
编辑:
正如 Jasd 所指出的,我之前发布了错误的代码。现在的代码就是有问题的代码。
【问题讨论】:
标签: javascript coffeescript meteor