- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在autoform docs ,有很多示例片段,但我无法让它们中的任何一个工作。主要是因为 autoform、meteor 和 JS 对我来说都是新的。
然而,我擅长改编例子,却找不到任何简单的例子。 This is one我挣扎着。我可以获得使用集合的简单自动表单(或快速表单)的完整工作示例吗?
假设我的文件分为
假设我正在使用一个名为“testTemplate”的模板和一个名为“testCollection”的集合
感谢您的帮助。
最佳答案
我会尽量做到简单。
首先创建项目并删除autopublish 和insecure
包
第二个放在 /server/testform.js
上。
TestCollection.allow({
insert:function(){return true;},
remove:function(){return true;},
update:function(){return true;},
})
和 publish功能
Meteor.publish("TestCollection", function () {
return TestCollection.find();
});
根据 Meteor 最佳实践,将集合声明放在 /lib/testform.js
中,而不是 /both/testform.js
,以确保它首先被评估。
TestCollection = new Mongo.Collection("TestCollection");
和 subscription .
if(Meteor.isClient){
Meteor.subscribe('TestCollection')
}
现在在 /client/testform.html
放这个。
<template name="testForm">
{{> quickForm collection="TestCollection" id="insertTestForm" type="insert"}}
</template>
现在在 /client/testform.js
上放置模式
TestCollection.attachSchema(new SimpleSchema({ //take this from docs.
title: {
type: String,
label: "Title",
max: 200
},
author: {
type: String,
label: "Author"
},
copies: {
type: Number,
label: "Number of copies",
min: 0
},
lastCheckedOut: {
type: Date,
label: "Last date this book was checked out",
optional: true
},
summary: {
type: String,
label: "Brief summary",
optional: true,
max: 1000
}
}));
注意
如果您是 Meteor/Javascript 的新手,请不要跳入像这样的复杂包。
运行它,看看它们是如何工作的。
meteor create --example todos
meteor create --example local market
对于 Javascript,本教程/指南对我帮助很大 How to Learn Javascript properly
关于javascript - 请求 Meteor + autoform 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28554221/
我有一个用户架构,用户可能有一个团队列表,如本部分所示: "teams": { type: [Object], optional: true, autoform: { label:
我已经在架构中定义了一个对象数组,现在想要将对象属性显示到我的模板中,但不知道如何执行此操作。 ingredients: { type: [Object],
我正在创建一个用户管理面板,我的添加用户模式看起来很好,其中每个输入占据整行,下一个输入位于下一行。在我的编辑用户模式中,输入仅用了半行。以前有人见过这种行为吗? 添加用户模板: {{#auto
我想使用 Meteor 的自动表单包为我的 CAS_Entry 集合创建一个表单。代码如下所示。我还添加了定义的钩子(Hook),不幸的是,其中仅执行 beginSubmit 和 before ,并且
在 meteor 自动表单中(使用经典的 aldeed 包: https://github.com/aldeed/meteor-autoform ),我有一个名为 'score' 的隐藏字段,其值是另
如果某个选项已在其中一个对象组中被选中,我想将其禁用。 因此,如果我选择“2013”然后添加另一个示例,则“2013”在该组中将不可用,除非在原始组中更改该选项。 有没有一种我缺少的简单方法可
我正在为 MeteorJS 使用很棒的 aldeed:autoform 包。我有一个自定义表单,可以让我创建数据库条目。 用户输入的表单字段之一是郊区,我使用 sergeyt:typeahead 包在
我有带有文本字段的页面,这些字段是必需的。我单击带有空字段的“提交”=> 带有红色边框的字段(因为它是必需的)。然后我更改页面并返回 => 仍然显示边框。页面更改时如何重置 meteor AutoFo
我有一个包含以下字段的 Meteor AutoForm 集合架构,我正试图使其独一无二。它不允许在相同的情况下使用相同的值,但是当我更改值的大小写时,会插入值,那么如何防止插入具有不同大小写的重复值?
当使用 autoform 和 type="method-update"meteormethod="someMethod" 时,该方法实际上不会被调用。 我遇到问题的自动表单: {{#autoForm
我一直在寻找 SO 问题的答案,这些问题应该非常简单,但对于我来说我无法弄清楚。 基本上我有一个带有两个选择控件的 meteor-autoform: {{#autoForm id="proc
我一直在我的 Meteor 项目中使用 Collection2 和 Autoform,让事情变得简单多了! 但是,当我删除 insecure 时,它不再插入(Autoform 提交按钮)。我预料到
在我的 Stacks 架构中,我有一个 dimensions 属性定义如下: dimensions: { type: [String], autoform: { opt
我有一个像这样的快速表格: {{> quickForm schema=competitorSchema id="newCompetitorForm"type="method"buttonContent
我正在使用 Autoform 和 Slingshot 进行 S3 交互。当用户提交表单时,我想拦截进程,通过Slingshot上传文件到S3,扩展doc返回 downloadUrl 的对象然后此时,返
我们有一个站点,在不同的页面/路线上有几个 AutoForms。如果用户在特定表单上触发验证并触发一些验证错误,然后使用该表单离开页面,当他们稍后返回该页面时,他们输入的数据已经消失,但任何验证错误仍
我遇到了 aldeed:autoform 的问题我无法解决,也不明白原因是什么。模板: {{> quickForm collection=Cases id="inserNewItem" type
自从我找到了我一直在寻找的第一部分的答案以来,我正在对原始问题进行一些更新。 新问题: 到目前为止,我有一个架构定义,它附加到 3 个集合,即 C1、C2、C3。 some_schema = ne
我有一个 meteor 应用程序,我在其中使用 Aldeed: Autoform 根据架构将生成的表单直接插入到数据库中。有没有一种方法可以让我使用自己的自定义按钮或输入字段,而不是使用自动表单提供的
我正在构建一个新的 Meteor 应用程序,并尝试在使用 Simple Schema/Collection2/Autoform trifecta(以下称为 Collection2)运行还是使用替代的
我是一名优秀的程序员,十分优秀!