- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我是 meteor 的新手,刚在 1.3 版发布后到达。由于省略了导入或导出,我一直在努力调试一些非常“愚蠢”的东西,因为大多数教程似乎都没有包含这些内容。因此,以下问题可能属于同一类型。
我想使用包 autoform,所以我刚刚添加了包。(之前也包含了 simple-schema 和 collection2)。
我遇到错误,模板未加载。
这是我的模板
<template name="addItem">
{{> quickForm collection="Items" id="addItemForm" type="insert" }}
</template>
我有我的 addItem.js
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Mongo } from 'meteor/mongo';
import { Items } from '/imports/collections/itemCollection.js';
import './addItem.html';
Template.addItem.onCreated(function bodyOnCreated(){
AutoForm.debug();
Meteor.subscribe('items');
});
Template.addItem.helpers({
Items() {
return Items.find({});
},
});
还有我的 itemCollection.js 文件
import { Mongo } from 'meteor/mongo';
export const Items = new Mongo.Collection('items');
Items.allow({
insert: () => false,
update: () => false,
remove: () => false
});
Items.deny({
insert: () => true,
update: () => true,
remove: () => true
});
Items.schema = new SimpleSchema({
name : {type : String},
supplier : {type : String},
Viscosity : {type : Number},
createdAt : {type : Date()},
owner : {type: String},
});
Items.attachSchema(Items.schema);
这是我在 chrome 控制台中得到的错误:
Exception in template helper: Error: Items is not in the window scope
at Object.lookup (http://localhost:3000/packages/aldeed_autoform.js?hash=5dbf44ff89f182bd8c2512330e170ef4d5bf9582:231:15)
at setDefaults (http://localhost:3000/packages/aldeed_autoform.js?hash=5dbf44ff89f182bd8c2512330e170ef4d5bf9582:3013:41)
at Object.AutoForm.parseData (http://localhost:3000/packages/aldeed_autoform.js?hash=5dbf44ff89f182bd8c2512330e170ef4d5bf9582:2771:10)
at Object.quickFormContext (http://localhost:3000/packages/aldeed_autoform.js?hash=5dbf44ff89f182bd8c2512330e170ef4d5bf9582:6696:33)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2994:16
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1653:16
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3046:66
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3045:27
at Object.Spacebars.call (http://localhost:3000/packages/spacebars.js?hash=65db8b6a8e3fca189b416de702967b1cb83d57d5:172:18)
debug.js:41 Exception in defer callback: TypeError: Cannot read property 'id' of null
at .<anonymous> (http://localhost:3000/packages/aldeed_autoform.js?hash=5dbf44ff89f182bd8c2512330e170ef4d5bf9582:6551:22)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1875:20
at Function.Template._withTemplateInstanceFunc (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:3687:12)
at http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1873:29
at Object.Blaze._withCurrentView (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:2214:12)
at viewAutorun (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1872:18)
at Tracker.Computation._compute (http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:351:36)
at new Tracker.Computation (http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:239:10)
at Object.Tracker.autorun (http://localhost:3000/packages/tracker.js?hash=6f5d0f5486aaa54b0abe636174eeb06dcc2a736b:590:11)
at Blaze.View.autorun (http://localhost:3000/packages/blaze.js?hash=ef41aed769a8945fc99ac4954e8c9ec157a88cea:1885:22)
有人可以帮助并告诉我我可能做错了什么吗?
最佳答案
您可以通过实现 Meteor 模板帮助器来解决此问题,该帮助器返回集合 Items
而不是游标,就像您现在所做的那样。
例如:
import {Items} from '/itemCollection.js';
Template.addItem.helpers({
items() {
return Items;
}
});
<template name="addItem">
{{> quickForm collection=items id="addItemForm" type="insert" }}
</template>
关于javascript - meteor 1.3 autoform/quickform 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36768454/
我有使用 QuickForm 的代码,它使用以下内容创建一个选择小部件: $form->addElement( 'select', 'state_id', 'State:', statesArray(
我正在使用 html Quickforms 和 php。我有一个表格。当字段值超过200并且他点击提交时我想显示一个弹出确认框,我该怎么做? 最佳答案 您需要 JavaScript 来弹出确认框。 类
我目前正在研究 HTML_QuickForm用于在 PHP 中生成表单。它似乎有点受限,因为很难插入我自己的 javascript 或自定义某些元素的显示和分组。 是否有任何可以提供更大灵 activ
我在上传其他字段中的图像时遇到问题。虽然其他字段的数据存在,但图像不存在,因此表单不会被验证。 这里是后端,具体看图片文件字段,标有#IMAGE from flask import Blueprint
我有这个 Meteor 模板: {{> quickForm collection="PersonalDetails" id="personalDetailsForm" type="insert"}
我是 meteor 的新手,刚在 1.3 版发布后到达。由于省略了导入或导出,我一直在努力调试一些非常“愚蠢”的东西,因为大多数教程似乎都没有包含这些内容。因此,以下问题可能属于同一类型。 我想使用包
在 QuickForm 中,它可以像这样完成: $form = new HTML_QuickForm2('changepassword'); $passwordold = $fs->addElemen
我无法让该应用程序在 Meteor 上运行。quickform 没有链接我的收藏。 “模板助手中的异常:错误:食谱不在窗口范围内” 这里有人可以帮忙吗? 这是我的快速表单代码 {{> quickF
我是一名优秀的程序员,十分优秀!