我第一次使用默认模式尝试collectionFS (v0.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的变量具有全局范围。所以我不明白怎么回事。
谢谢!
发布于 2014-07-23 07:27:12
您的集合是本地定义的。如果从集合中删除关键字var,则可以全局使用该集合。
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/uploads"})]
});https://stackoverflow.com/questions/24903731
复制相似问题