2016-06-23 20 views
2

我無法使應用程序在Meteor上工作。 quickform沒有鏈接我的收藏。模板助手中的流星quickForm異常:錯誤:食譜不在窗口範圍內

「例外模板幫手:錯誤:食譜不在窗口範圍」

任何人都可以幫忙嗎?

這裏是我的quickform代碼

<template name="NewRecipe"> 
 
\t <div class="new-recipe-container"> 
 
\t \t {{> quickForm collection="Recipes" id="insertRecipeForm" type="insert" class="new-recipe-form" }} 
 
\t \t 
 
\t </div> 
 
</template>

,這裏是我的收藏模式

Recipes = new Mongo.Collection('recipes'); 
 

 
RecipeSchema = new SimpleSchema({ 
 
\t name: { 
 
\t \t type: String, 
 
\t \t label:"Name" 
 
\t }, 
 
\t desc: { 
 
\t \t type: String, 
 
\t \t label:"Description" 
 
\t }, 
 
\t author: { 
 
\t \t type: String, 
 
\t \t label:"Author", 
 
\t \t autoValue: function() { 
 
\t \t \t return this.userId 
 
\t \t } 
 
\t }, 
 
\t createdAt: { 
 
\t \t type: Date, 
 
\t \t label:"Created At", 
 
\t \t autoValue: function() { 
 
\t \t \t return new Date() 
 
\t \t } 
 
\t } 
 

 
}); 
 

 
Recipes.attachSchema(RecipeSchema);

+0

{{> quickForm collection = Recipes id =「insertRecipeForm」type =「insert」class =「new-recipe-form」}}帶有集合的模式名稱 – channasmcs

回答

4

我不是可以評論你的問題,因爲我的名聲不到50位,所以我把這張貼作爲答案。

我遵循相同的中級流星等級上調Tuts,但通過嘗試遵循new Application structure and import syntax,因爲我正在使用Meter 1.3,並且我想遵循最新的最佳做法。

我有這個錯誤,因爲當我試圖寫

{{> quickForm collection="Recipes" id="insertRecipeForm" type="insert" class="new-recipe-form" }} 

collection="Recipes" (with quotations)

這是因爲流星1.3的問題,因爲有流星1.3沒有「全局」的東西再次感謝es2015模塊。我沒有像你那樣定義集合(並且像Level Up Tuts中的Scott),我使用const聲明來定義集合,並使用ec2015模塊語法(請參閱我提供的github問題)導出它。點作爲我的收藏不在全球範圍。所以不是我不得不寫一個模板助手返回的收集和編寫quickForm模板包含這樣的:

collection=Recipes (without quotations)

現在食譜這裏是一個模板,幫助其返回食譜集合對象

Template.NewRecipe.helpers({ 
    Recipes(){ 
    return Recipes; 
    } 
}); 

我從here

我知道了這個問題但是既然您使用的流星的舊應用程序結構方法(我想?)流星仍然支持,我現在可能只會想到一個問題,最新版本的autoform是專門爲Meteor 1.3設計的。我搜索了流星論壇,並且我得到了一個post,它們有同樣的擔憂。

您可以嘗試兩件事情:

  1. 嘗試他做了什麼來解決這些全球性的錯誤,即明確集合添加到窗口對象。
  2. 嘗試像他一樣恢復到autoform的舊版本。

也許讓我知道每個的發現?

相關問題