【问题标题】:Meteor autoform method-update not working流星自动形成方法更新不起作用
【发布时间】:2015-09-23 19:00:38
【问题描述】:

当使用带有type="method-update" meteormethod="someMethod" 的autoform 时,该方法实际上不会被调用。

我遇到问题的自动表单:

{{#autoForm id="archiveIssue" type="method-update" meteormethod="editIssue" collection="Collections.Issues" validation="keyup" doc=doc autosaveOnKeyup="true" resetOnSuccess="true"}}
  <fieldset>
    {{> afQuickField name="Archived.Archived_By" id="Archived.Archived_By" autocomplete="off"}}
    {{> afQuickField name="Archived.Archive_Notes" id="Archived.Archive_Notes" autocomplete="off" rows=5}}
      <div>
      <button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#archiveIssue">Submit</button>
      <button type="reset" class="btn btn-default">Reset</button>
      </div>
    </fieldset>
{{/autoForm}}

这是我试图调用的方法(PRINT 永远不会出现在服务器控制台中):

editIssue: function(doc) {
  console.log("PRINT");
  Collections.Issues.update({
    "_id": doc._id
  },
  {
    $set: {
      "Archived.Archived": true,
      "Archived.Archived_By": doc.Archived_By,
      "Archived.Archive_Notes": doc.Archive_Notes
    }
  });
}

应该有助于获取文档的 2 个函数:

  Template.archiveIssue.helpers({
    doc: function () {
      var tmp = Session.get("archiveDoc");
      return tmp;
    }
  });

  Template.archiveIssueModal.events({
    "click .archiveButton": function (event) {
      Session.set("archiveDoc", this);
      }
    });

架构

Schema.Archived = new SimpleSchema({
  Archived: {
    type: Boolean,
    optional: true
  },
  Archived_By: {
    type: String,
    optional: true
  },
  Archive_Notes: {
    type: String,
    max: 200,
    optional: true
  }
});

Schema.Issues = new SimpleSchema({
  Description: {
    type: String,
    max: 500,
    optional: true
  },
  Comments: {
    type: [Schema.Comments],
    max: 500,
    optional: true
  },
  User: {
    type: String,
    label: "User",
    optional: true
  },
  Archived: {
    type: Schema.Archived,
    optional: true
  },
});

【问题讨论】:

  • 您的问题集合中是否附加了 SimpleSchema?
  • 是的,我已经用正在使用的模式更新了帖子。

标签: javascript meteor meteor-autoform meteor-helper


【解决方案1】:

不确定您现在是否需要答案。 您需要像这样使用 Meteor.methods 进行定义。

Meteor.methods({
  demoSubmission: function () {

【讨论】:

    猜你喜欢
    • 2017-04-18
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 2017-12-25
    • 1970-01-01
    • 2015-09-13
    • 1970-01-01
    相关资源
    最近更新 更多