【发布时间】:2015-02-11 12:10:28
【问题描述】:
我正在使用 Meteor.js、Summernote 和 Collection FS 开展一个项目。
首先,这是我的代码。
Template.postSubmit.rendered = function() {
$('#summernote').summernote({
height: 400,
maxHeight:800,
minHeight:250,
onImageUpload: function(files, editor, $editable) {
Images.insert(files[0], function (err, fileObj) {
editor.insertImage($editable, fileObj.url());
});
}
});
插入后的图像确实成功进入指定的 URL 以进行图像存储。这是 CollectionFS javascript。
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: "~/img"})]
});
Images.allow({
insert: function() {
return true;
},
update: function() {
return true;
},
remove: function() {
return true;
},
download: function() {
return true;
}
});
我想知道是否有人可以引导我朝着正确的方向前进。我被告知回调的 URL 没有定义。因此,我被要求使用 setTimeout 函数尝试此代码。但是,我仍然没有运气。
onImageUpload: function(files, editor, $editable) {
Images.insert(files[0], function (err, fileObj) {
setTimeout(function() {
editor.insertImage($editable, fileObj.url());
}, 300)
});
}
有没有人以这种方式在 Meteor.js 和 collectionFS 中成功使用summernote?
如果是这样,请帮助我。如果这个问题得到解决,我将为许多流星.js 用户发布教程。我相信这将是一个巨大的贡献。
另外,即使您不使用 Meteor.js 或 CollectionFS,如果您能投入两分钱,我们将不胜感激。
谢谢!
【问题讨论】:
标签: javascript file-upload collections meteor summernote