gpt4 book ai didi

javascript - Meteor autoform 方法更新不起作用

转载 作者:行者123 更新时间:2023-11-28 00:07:01 26 4
gpt4 key购买 nike

当使用 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
}
});
}

有助于获取文档的 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
},
});

最佳答案

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

Meteor.methods({
demoSubmission: function () {

关于javascript - Meteor autoform 方法更新不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31249104/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com