Meteor autoform方法 - 更新不起作用

时间:2015-07-06 14:57:25

标签: javascript meteor meteor-autoform meteor-helper

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

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
  },
});

1 个答案:

答案 0 :(得分:1)

现在还不确定你是否需要答案。 你需要像这样定义Meteor.methods。

Meteor.methods({
  demoSubmission: function () {