请求Meteor+自动成型示例
Meteor + autoform example requested
在自动表单文档中,有许多示例片段,但我无法使其中任何一个发挥作用。主要是因为自动成型、流星和JS对我来说都是新的
然而,我很善于改编例子,但找不到任何简单的例子。这是一个我挣扎的问题。我能得到一个使用集合的简单自动表单(或快速表单)的完整示例吗?
- 假设我已经安装了aldeed:autoform和aldeed:collection2
-
假设我的文件被划分为
- both/testform.js
- server/testform.js
- client/testform.js
- client/testform.js
-
假设我使用的是一个名为"testTemplate"的模板和一个称为"testCollection"的集合
谢谢你的帮助。
我会尽量简化它。
首先创建项目并删除autopublish and insecure
包
第二个放在/server/testform.js
上。
TestCollection.allow({
insert:function(){return true;},
remove:function(){return true;},
update:function(){return true;},
})
以及发布功能
Meteor.publish("TestCollection", function () {
return TestCollection.find();
});
关于允许/拒绝规则的更多信息
按照Meteor最佳实践,将集合声明放在/lib/testform.js
中,而不是/both/testform.js
,以确保首先对其进行评估。
TestCollection = new Mongo.Collection("TestCollection");
以及订阅。
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,本教程/指南对我如何正确学习Javascript有很大帮助。
相关文章:
- Meteor如何接收HTTP请求
- Meteor-将选定窗体中的对象添加到集合中
- Meteor上的启动页面
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- Meteor-添加用户自定义字段的方法不起作用
- Meteor忘记了密码的实现
- 链接所有<a>Meteor
- 在Meteor项目中安装并包含npm模块后出错
- Meteor JS中代码的重复使用部分
- Meteor Router数据函数被调用两次
- 基于localStorage的Meteor激活模板
- React+Meteor:this.ops返回未定义
- 如何将PHP get查询转换为Meteor's HTTP.get()
- 如何将javascript变量传递到Meteor Spacebars模板中
- 部署时使用npm包时发生Meteor错误
- Meteor如何运行服务器端python脚本
- 谷歌地图根本不适用于Meteor-iOS
- 请求Meteor+自动成型示例
- 如何添加我自己的Meteor.users个人资料;使用aldeed自动成型和collection2
- 仅对时间使用Meteor自动成型bs日期时间选择器