热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在Meteor中使用autoform将postId添加到注释中-AddpostIdtocommentswithautoforminMeteor

HowcanIlinkaddpostIdtocommentswhenusingmeteor-autoform?使用meteor-autoform时,如何将postId链接到注释?

How can I link add postId to comments when using meteor-autoform?

使用meteor-autoform时,如何将postId链接到注释?

I have tried

我努力了

AutoForm.hooks({
  insertCommentForm: {
    formToDoc: function(doc) {
      doc.postId = this.formAttributes.parentContext._id;
      return doc;
    },
  }
});

and

AutoForm.hooks({
  insertCommentForm: {
    formToDoc: function(doc) {
      doc.postId = Template.parentData(1)._id;
      return doc;
    },
  }
});

and

AutoForm.hooks({
  insertCommentForm: {
    before: {
      method: function(doc) {
        doc.postId = this.formAttributes.parentContext._id;
        return doc;
      }
    }
  }
});

and

AutoForm.hooks({
  insertCommentForm: {
    before: {
      method: function(doc) {
        doc.postId = Template.parentData(1)._id;
        return doc;
      }
    }
  }
});

but postId is undefined no matter what I do.

但无论我做什么,postId都是不确定的。

Edit

I use it like this:

我这样使用它: