Tag: meteor autoform

如何使一个领域取决于其他领域的价值meteorautoform?

我是meteor的新手,我想创build一个表单,其中一个字段的值决定了autoform中另一个字段的值 。 让我们把安装types设置为“A”,“B”和“C”,所以当我select“A”时,autoform将被加载。 我已经把这个表格作为通用的,即它将显示给所有A,B和C. {{#each users}} {{> afQuickField name='userEmail' value=userEmail readOnly=true }} {{> afQuickField name='Setup' value=type readOnly=true}} {{> afQuickField name='Profile' options='allowed' }} {{> afQuickField name='Purpose' }} {{> afQuickField name='count' options='allowed' }} {{> afQuickField name='PackageDirectory' options='allowed' }} {{> afQuickField name="logName" options=LogName }} {{/each}} 计数选项应该是: 1.对于“A”计数选项应该是9,11,12。 2.“B”是1。 3.“C”是5。 在架构中,我写了这样的代码 Setup:{ type: String, label:"Setup", optional:false, defaultValue:type }, count:{ […]

用meteorautoform预览

我用meteor-autoform {{> quickForm collection="Pages" id="insertPageForm" type="insert"}} 但我也想在窗体下面有一个预览区域,就像这里的SO一样。 我只是不知道如何绑定一个键盘触发器的autoform领域。 用一个简单的帮手,我可以有HTML: <textarea class="text"></textarea> <div class="preview"></div> 和js: "change .text": function (e) { $(".preview").text($(e.target).text()); } 或类似的东西。

在Meteor中为每个表单定义autoform钩子

我有一个meteor的每个循环,我使用autoform来更新每个项目(就像http://autoform.meteor.com/update-each中所述 )。 我的问题是,我通常通过钩子创build通知 AutoForm.hooks({ myFormId: { onSuccess: function(formType, result) { Notifications.success('Title', 'Text.'); } } }); 但是因为我所有的表单都有唯一的ID,所以我不能使用它。 如何创build一个匹配模板中所有表单的钩子,或者是一个与正则expression式匹配的名称“unique-id-?” 哪里? 是docId?

在meteor中用autoform添加postId注释

如何使用meteor-autoform将postId链接到注释中? 我努力了 AutoForm.hooks({ insertCommentForm: { formToDoc: function(doc) { doc.postId = this.formAttributes.parentContext._id; return doc; }, } }); 和 AutoForm.hooks({ insertCommentForm: { formToDoc: function(doc) { doc.postId = Template.parentData(1)._id; return doc; }, } }); 和 AutoForm.hooks({ insertCommentForm: { before: { method: function(doc) { doc.postId = this.formAttributes.parentContext._id; return doc; } } } }); 和 AutoForm.hooks({ insertCommentForm: { before: { […]

用meteorautoform提交后创build文档

我正在使用meteor-autoform 。 我创build我的表单 {{> quickForm collection="Messages" id="insertMessageForm" type="insert" fields="text"}} 它插入消息,因为它应该但我也想在通知集合中创build一个文档。 如何确保每次创build新消息时都会创build通知? 我想创build通知每次在我的应用程序集合中创build一个新的文档。 这怎么能做到最聪明呢? 我可以创build一个afterCreate信号或什么?

如何使用自动值在SimpleSchema Meteor中定义子文档,而不将其插入每个父文档插入?

我试图为一个子文档集合定义一个模式,父文档和子文档都有自动值字段,应该在插入时设置。 问题是,当我尝试插入一个新的父文档(没有任何子文档),我得到一个错误,指出子文档字段是必需的。 以下是重现问题的完整代码: main.js ChatRooms = new Meteor.Collection("chatRooms"); schema_ChatRooms_ChatMesssage = new SimpleSchema({ userId: { type: String, label: "User ID", autoValue: function() { if (this.isInsert) { if (! this.isFromTrustedCode) { return this.userId; } } else { this.unset(); }}, autoform: { omit: true } }, content: { type: String, label: "Content", max: 1000, min: 1 }, creationDate: […]

获取autoform非集合表单的方法返回值

我想使用meteorautoform为我的非收集forms。 我尝试这种方法,但我想获得方法的返回值,并显示在客户端上。 请指导我如何做到这一点。 这是我的模式( common.js ): Schema = {}; Schema.echoSchema = new SimpleSchema({ echoText: { type: String, label: "Echo Text", max: 50 } }); 这是我在客户端( client.js )上的代码: Template.showEcho.helpers({ getEchoFormSchema: function() { return Schema.echoSchema; } }); 这是我在服务器上的代码( server.js ): Meteor.methods({ echoMethod: function (doc) { check(doc, Schema.echoSchema); return doc.echoText; }, }); 这是我的表单模板( showEcho.html ): <template name="showEcho"> {{#autoForm […]

meteor中钩子无功variables的变化值

我有 Template.templateName.onCreated(function() { this.variableName = new ReactiveVar; this.variableName.set(true); }); 并在templateName我有一个autoform 。 提交autoform时,我需要设置被动variablesvariableName为false 。 我努力了 AutoForm.hooks({ myForm: { onSuccess: function(operation, result) { this.variableName.set(false); }, } }); 但是this.以后它不起作用this. 没有像helpers和events那样引用template templateName 。 如果我使用会话,它会起作用,因为它们不限于/限于特定的模板。 我能做些什么来改变autoform钩子中的无功variables? 我也试过了 AutoForm.hooks({ myForm: { onSuccess: function(operation, result) { this.template.variableName.set(false); this.template.parent.variableName.set(false); this.template.parent().variableName.set(false); this.template.parentData.variableName.set(false); this.template.parentData().variableName.set(false); this.template.parentView.variableName.set(false); this.template.parentView().variableName.set(false); }, } }); 当使用console.log(this.template)它打印一个对象。 如果我使用console.log(this.template.data)我会得到 Object {id: "myForm", collection: […]

与meteor的AutoForm的可编辑表

我怎样才能在meteor中创build一个带有input字段的表格。 我已经使用http://autoform.meteor.com/update-each的例子,但他们只使用1input字段。 该function适用​​于此代码: <tbody> {{#each persons}} {{#autoForm id=makeUniqueID type="update" collection=Collections.Persons doc=this autosave=true}} <tr> <td>{{> afFieldInput name="fullName" label=false}}</td> <td>{{> afFieldInput name="email" label=false}}</td> <td>{{> afFieldInput name="address" label=false}}</td> <td><button type="submit" class="btn btn-xs btn-danger">Delete</button></td> </tr> {{/autoForm}} {{/each}} </tbody> 但是它在每个<tr>周围都创build了一个<form>元素,它把我的html搞砸了。 什么是正确的方法来做到这一点?