【问题标题】:Meteor Quick Form doesnt submitMeteor 快速表单不提交
【发布时间】:2017-06-07 06:05:42
【问题描述】:

我正在做 LevelUpTuts 的“中级 Meteor 教程 #8 - 插入权限、发布和流星玩具”,我的问题是我无法提交我检查了 5 次代码的表单,但我认为一切都是正确的,我正在运行流星 1.4这是我的代码

我的 Recipes.js 文件

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


Recipes.allow({
insert: function(userId, doc) {
    return !!userId;
}
});

RecipeSchema = new SimpleSchema ({
    name: {
        type: String,
        label: "Name"
    },
    desc: {
        type: String,
        label: "Description"
    },
    author: {
        type: String,
        label: "Author",
        autoValue: function() {
            return this.userID
        },
        autoform: {
            type: "hidden"
        },
    },
    createdAt: {
        type: Date,
        label: "CreatedAt",
        autoValue: function() {
        return new Date()
        },
         autoform: {
            type: "hidden"
        },
    },
});

Recipes.attachSchema( RecipeSchema);

我的食谱.js

Meteor.subscribe('recipes');

我的新食谱.js

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

还有 publis.js 文件

Meteor.publish('recipes', function(){
    return Recipes.find({author: this.userId});
});

请帮帮我,我不知道我做错了什么

【问题讨论】:

    标签: javascript html meteor meteor-blaze meteor-autoform


    【解决方案1】:

    我没有给你答案(至少现在还没有),但我将其作为答案发布,以便我可以提供一些格式化代码。

    您在 NewRecipe.js 下发布了一些代码,但我假设视图代码在 NewRecipe.html 中。尝试两件事:

    首先,将这段代码放入NewRecipe.js onCreated():

    SimpleSchema.debug = true;
    AutoForm.addHooks(null, {
        onError: function(name, error, template) {
            console.log(name + " error:", error);
        }
    });
    

    这将为快速表单启用一些调试。

    其次,在架构定义中,注释掉 Recipes.allow() 块,看看这是否是阻止保存数据的原因。

    然后报告情况。

    【讨论】:

    • 您好 Zim 感谢您的帮助,但我今天再次打开了我的网站,现在整个网站都没有显示快速表单。流路由器没问题,我检查了一个测试页面,里面只有 test 这个词,它出现了,但是当我在其中输入快速表单的命令时,整个页面又是白色的 --> 所以我重新安装了 quickform 但这没有帮助,所以我比昨天更落后;(
    猜你喜欢
    • 2014-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多