【问题标题】:Getting Exception in template helper: quickFormContext with aldeed:autoform在模板助手中获取异常:quickFormContext with aldeed:autoform
【发布时间】:2015-12-06 10:45:56
【问题描述】:

我遇到了aldeed:autoform 的问题,我无法解决,也不明白是什么原因。模板:

<template name="staffCaseEdit">
  {{> quickForm collection=Cases id="inserNewItem" type="insert"}}
</template>

我使用aldeed:collection2aldeed:simple-schema 来管理集合。所以,我有Case 架构和Cases 集合,都在/lib 中定义,因此它们也应该在客户端可用。

接下来是路线:

FlowRouter.route('/staff/case/:id', {
    triggersEnter: [
        AccountsTemplates.ensureSignedIn
    ],
    subscriptions: function (params) {
        this.register('theCase', Meteor.subscribe('theCase', params.id));
    },
    action: function (params, queryParams) {
        return BlazeLayout.render('container', {
            main: 'staffCaseEdit',
            id: params.id
        });
    }
});

当然,theCase 已发布:

Meteor.publish('theCase', function (id) {
    return Cases.find({
        id: Number(id)
    });
});

在浏览器控制台中,存在案例:

> Cases
< Object

> Cases.find().count()
< 1

我认为这足以让 quickForm 正确使用集合(它需要一个作为参数之一)。

问题是,在客户端,我遇到了错误

Exception in template helper: quickFormContext@http://localhost:3000/packages/aldeed_autoform.js?b0918af3b0bb0ae387d80c71f4230daca94cae11:6851:34

我无法追踪。结果,没有显示任何表单(实际上,整个 DOM 都是空的。

我应该寻找什么?这个特定问题的根源可能是什么?

【问题讨论】:

  • 您是否正在使用 Chrome 的控制台进行调试?它通常比“模板助手中的异常”更明确

标签: javascript meteor meteor-autoform meteor-helper


【解决方案1】:

这里有点暗中拍摄,我不知道它是否能解决你的问题,但它肯定会有所帮助......使用这个:

<template name="staffCaseEdit">
  {{> quickForm collection="Cases" id="inserNewItem" type="insert"}}
</template>

您将变量 Cases 传递给集合参数,而不是传递目标集合的名称 "Cases"

【讨论】:

  • 成功了!!!1 我花了 3 个小时疯狂地解决这个问题,解决方案在引号中。 FML。
猜你喜欢
  • 2017-07-30
  • 1970-01-01
  • 2018-09-22
  • 2015-09-05
  • 2016-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-18
相关资源
最近更新 更多