2016-05-16 37 views
0

我有一個架構與集合:無法呈現的自動窗體模板

export const Cources = new Meteor.Collection('Cources'); 

Cources.schema = new SimpleSchema({ 
    courcePath: { 
    type: String, 
    label: 'Cource path' 
    }, 
    courceTitle: { 
    type: String, 
    label: 'Cource title', 
    max: 200 
    }, 
    courceDescription: { 
    type: String, 
    label: 'Cource description' 
    }, 
    lessonsNumber: { 
    type: Number, 
    label: 'Lessons number', 
    min: 1 
    }, 
    courceDuration: { 
    type: String, 
    label: 'Cource duration' 
    } 
}); 

Cources.attachSchema(Cources.schema); 

而且模板:

<template name="AddCource_page"> 
    <div class="container"> 
    {{> quickForm collection="Cources" id="insertCourceForm" type="insert"}} 
    </div> 
</template> 

但是,形式不渲染和存在錯誤控制檯:Error: Cources is not in the window scope。當我添加助手時也會出現同樣的問題。我如何解決它?謝謝。

+0

你可能是指「課程」而不是「Cource」。無論如何,如果你刪除'export const',它是否工作? –

+0

嘗試刪除'Course.schema'並改爲使用'coursesSchema' –

回答

0

我認爲Cources.schema導致該問題。在這裏你可以像這樣定義模式。

1:

架構部分:

export const Cources = new Meteor.Collection('Cources'); 

Cources = attachSchema(new SimpleSchema({ 
    courcePath: { 
    type: String, 
    label: 'Cource path' 
    }, 
    courceTitle: { 
    type: String, 
    label: 'Cource title', 
    max: 200 
    }, 
    courceDescription: { 
    type: String, 
    label: 'Cource description' 
    }, 
    lessonsNumber: { 
    type: Number, 
    label: 'Lessons number', 
    min: 1 
    }, 
    courceDuration: { 
    type: String, 
    label: 'Cource duration' 
    } 
}) 
); 

第二:

架構部分: 出口常量Cources; Cources.Collection = new Meteor.Collection('Cources');

Cources.schema = new SimpleSchema({ 
    courcePath: { 
    type: String, 
    label: 'Cource path' 
    }, 
    courceTitle: { 
    type: String, 
    label: 'Cource title', 
    max: 200 
    }, 
    courceDescription: { 
    type: String, 
    label: 'Cource description' 
    }, 
    lessonsNumber: { 
    type: Number, 
    label: 'Lessons number', 
    min: 1 
    }, 
    courceDuration: { 
    type: String, 
    label: 'Cource duration' 
    } 
}); 

Cources.Collection(Cources.schema); 

而且模板部分

<template name="AddCource_page"> 
    <div class="container"> 
    {{> quickForm collection="Cources.Collection" id="insertCourceForm" type="insert"}} 
    </div> 
</template> 
0

你不必做任何其他不是改變語法如下:

Schemas.Cources = new SimpleSchema({}); 
Cources.attachSchema(Schemas.Cources); 

您已經使用Cources.schema,而不是架構。資源