Javascript Meteor AutoForm挂钩未触发,获取ec.invalidKeys不是一个函数错误
在我的整个应用程序中,我多次尝试使用autoform,但我认为autoform和MaterializeCSS模板之间存在真正的冲突。不管怎样,我一直有以下错误: 模式:Javascript Meteor AutoForm挂钩未触发,获取ec.invalidKeys不是一个函数错误,javascript,meteor,meteor-autoform,Javascript,Meteor,Meteor Autoform,在我的整个应用程序中,我多次尝试使用autoform,但我认为autoform和MaterializeCSS模板之间存在真正的冲突。不管怎样,我一直有以下错误: 模式: import SimpleSchema from 'simpl-schema'; import { Materials } from '/imports/api/materials/materials.js'; import { PurchasesAPI } from '/imports/api/purchases/api.js
import SimpleSchema from 'simpl-schema';
import { Materials } from '/imports/api/materials/materials.js';
import { PurchasesAPI } from '/imports/api/purchases/api.js';
import '../../ui/components/purchasing/purchasing-autocomplete-list-template.html';
export const purchasingCreatePurchaseSchema = new SimpleSchema({
userId: {
type: String,
autoValue: function () {
if (this.isInsert) {
console.log("this is insert");
console.log(Meteor.userId());
return Meteor.userId();
} else if (this.isUpsert) {
return { $setOnInsert: Meteor.userId() };
}
this.unset(); // Prevent user from supplying their own value
return undefined;
},
autoform: {
omit: true
}
},
createdOn: {
type: Date,
// defaultValue: new Date(),
autoValue: function () {
if (this.isInsert) {
return new Date();
}
this.unset(); // Prevent user from supplying their own value
return undefined;
},
autoform: {
omit: true
}
},
purchaseOrderNo: {
type: String,
autoValue: function () {
if (this.isInsert) {
return PurchasesAPI.newPurchaseOrder();
}
this.unset(); // Prevent user from supplying their own value
return undefined;
}
},
orderedDate: {
type: Date,
autoform: {
afFieldInput: {
class: 'datepicker'
}
}
},
supplier: {
type: String,
defaultValue: "Not Specified"
},
material: {
type: String,
autoform: {
afFieldInput: {
type: 'autocomplete-input',
placeholder: 'Material',
settings: function () {
return {
position: "top",
limit: 20,
rules: [
{
collection: Materials,
field: "material",
matchAll: true,
template: Template.Purchasing_material_item
}
]
}
}
}
}
},
orderConfirmationDate: {
type: Date,
optional: true,
autoform: {
afFieldInput: {
class: 'datepicker'
}
}
},
estimatedTimeOfArrival: {
type: Date,
optional: true,
autoform: {
afFieldInput: {
class: 'datepicker'
}
}
},
actualTimeOfArrival: {
type: Date,
optional: true,
autoform: {
afFieldInput: {
class: 'datepicker'
}
}
}
});
HTML
当按下提交按钮时,我得到:
VM32227 aldeed_autoform.js:7702 Uncaught TypeError: ec.invalidKeys is not a function
at failedValidation (VM32227 aldeed_autoform.js:7702)
at Object.autoFormSubmitHandler (VM32227 aldeed_autoform.js:7836)
at VM32193 blaze.js:3775
at Function.Template._withTemplateInstanceFunc (VM32193 blaze.js:3744)
at Blaze.View.<anonymous> (VM32193 blaze.js:3774)
at VM32193 blaze.js:2617
at Object.Blaze._withCurrentView (VM32193 blaze.js:2271)
at Blaze._DOMRange.<anonymous> (VM32193 blaze.js:2616)
at HTMLFormElement.<anonymous> (VM32193 blaze.js:863)
at HTMLDivElement.dispatch (VM32156 modules.js:17882)
failedValidation @ VM32227 aldeed_autoform.js:7702
autoFormSubmitHandler @ VM32227 aldeed_autoform.js:7836
(anonymous) @ VM32193 blaze.js:3775
Template._withTemplateInstanceFunc @ VM32193 blaze.js:3744
(anonymous) @ VM32193 blaze.js:3774
(anonymous) @ VM32193 blaze.js:2617
Blaze._withCurrentView @ VM32193 blaze.js:2271
(anonymous) @ VM32193 blaze.js:2616
(anonymous) @ VM32193 blaze.js:863
dispatch @ VM32156 modules.js:17882
elemData.handle @ VM32156 modules.js:17690
Navigated to http://localhost:3000/purchasing/purchases/new-purchase?purchaseOrderNo=&orderedDate=&supplier=Not+Specified&material=&orderConfirmationDate=&estimatedTimeOfArrival=&actualTimeOfArrival=
VM32227 aldeed_autoform.js:7702未捕获类型错误:ec.invalidKeys不是函数
验证失败时(VM32227 aldeed_autoform.js:7702)
在Object.autoFormSubmitHandler(VM32227 aldeed_autoform.js:7836)
在VM32193 blaze.js:3775
在Function.Template._中使用TemplateInstanceFunc(VM32193 blaze.js:3744)
在Blaze.View。(VM32193 blaze.js:3774)
在VM32193 blaze.js:2617
在Object.Blaze._和当前视图(VM32193 Blaze.js:2271)
在火焰中。(VM32193 blaze.js:2616)
在HTMLFormElement。(VM32193 blaze.js:863)
在htmldevelment.dispatch(VM32156 modules.js:17882)
验证失败@VM32227 aldeed_autoform.js:7702
autoFormSubmitHandler@VM32227 aldeed_autoform.js:7836
(匿名)@VM32193 blaze.js:3775
模板._withTemplateInstanceFunc@VM32193 blaze.js:3744
(匿名)@VM32193 blaze.js:3774
(匿名)@VM32193 blaze.js:2617
Blaze._withCurrentView@VM32193 Blaze.js:2271
(匿名)@VM32193 blaze.js:2616
(匿名)@VM32193 blaze.js:863
dispatch@VM32156 modules.js:17882
elemData.handle@VM32156 modules.js:17690
导航到http://localhost:3000/purchasing/purchases/new-采购?采购订单号=&orderedDate=&supplier=未指定+材料=&orderConfirmationDate=&estimatedTimeOfArrival=&actualTimeOfArrival=
如果我试图用Template.Purchasing\u new\u Purchasing\u form.events({'submit':function(){…}})覆盖submit按钮,我的钩子也不会触发。
它也不起作用
如果有人能帮我做到这一点,我将不胜感激,希望我能开始在我的应用程序中使用更多的自动表单,但目前我只是从头开始编写表单,然后应用手动验证,而无需反应性验证。这是AutoForm固有的问题还是我做错了什么 设法解决了这个问题
我将
Autoform更新为6.3.0
,Simple schema
更新为>1.4,删除了所有其他相关的自动表单包,如autocomplete
,以及Autoform materialize
,并开始工作。您使用的是哪个版本的Autoform(以及哪个collection2核心和SimpleSchema)?@Jankapunkt“aldeed:autoform 5.8.1*,“Simple schema”:“^0.3.2”
,和mpowaga:autoform autocomplete
0.0.2”,不使用collection2 core
。钩住事件的方式可能没有错,但我很好奇如果这样做会发生什么:'submit#createNewPurchase':function(){…}
在这里,您基本上可以将表单的id指定给事件映射。
VM32227 aldeed_autoform.js:7702 Uncaught TypeError: ec.invalidKeys is not a function
at failedValidation (VM32227 aldeed_autoform.js:7702)
at Object.autoFormSubmitHandler (VM32227 aldeed_autoform.js:7836)
at VM32193 blaze.js:3775
at Function.Template._withTemplateInstanceFunc (VM32193 blaze.js:3744)
at Blaze.View.<anonymous> (VM32193 blaze.js:3774)
at VM32193 blaze.js:2617
at Object.Blaze._withCurrentView (VM32193 blaze.js:2271)
at Blaze._DOMRange.<anonymous> (VM32193 blaze.js:2616)
at HTMLFormElement.<anonymous> (VM32193 blaze.js:863)
at HTMLDivElement.dispatch (VM32156 modules.js:17882)
failedValidation @ VM32227 aldeed_autoform.js:7702
autoFormSubmitHandler @ VM32227 aldeed_autoform.js:7836
(anonymous) @ VM32193 blaze.js:3775
Template._withTemplateInstanceFunc @ VM32193 blaze.js:3744
(anonymous) @ VM32193 blaze.js:3774
(anonymous) @ VM32193 blaze.js:2617
Blaze._withCurrentView @ VM32193 blaze.js:2271
(anonymous) @ VM32193 blaze.js:2616
(anonymous) @ VM32193 blaze.js:863
dispatch @ VM32156 modules.js:17882
elemData.handle @ VM32156 modules.js:17690
Navigated to http://localhost:3000/purchasing/purchases/new-purchase?purchaseOrderNo=&orderedDate=&supplier=Not+Specified&material=&orderConfirmationDate=&estimatedTimeOfArrival=&actualTimeOfArrival=