繁体   English   中英

流星自动成型方法更新不起作用

[英]Meteor autoform method-update not working

当将autoform与type="method-update" meteormethod="someMethod"该方法实际上不会被调用。

我遇到的自动表单有问题:

{{#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
    }
  });
}

这两个有助于获取文档的功能:

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

不知道您现在是否需要答案。 您需要使用Meteor.method这样定义。

Meteor.methods({
  demoSubmission: function () {

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM