collectionFS:图像未定义

时间:2014-07-23 06:56:06

标签: meteor

我第一次使用默认模式尝试收集FS(v 0.4.3),但没有运气:

我在/ models:collection_fs.js

中创建了一个文件
var Images = new FS.Collection("images", {
    stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});

然后我在表单事件中添加了一个模板:upload_form.coffee

Template.uploadForm.events "change .myFileInput": (event, template) ->
  FS.Utility.eachFile event, (file) ->
    Images.insert file, (err, fileObj) ->

但它一直告诉我:

Uncaught ReferenceError: Images is not defined

我知道collection_fs.js运行(使用console.log检查)。如果我没有错,前面带var的变量具有全局范围。所以我不明白什么是错的。

谢谢!

1 个答案:

答案 0 :(得分:8)

您的收藏是本地定义的。如果从集合中删除关键字var,则可以全局使用该集合。

Images = new FS.Collection("images", {
    stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});
相关问题