【问题标题】:Date disappear if you use bootstrap date picker如果您使用引导日期选择器,日期会消失
【发布时间】:2016-07-11 11:57:58
【问题描述】:

从 github 中提取工作示例,dateExample。

我之前问过这个问题,但是这个建议没有奏效,所以我创建了一个小的工作示例。如果有人能指出我正确的方向,我可以把它放到网上并在此处发布链接。这是一个流星应用程序。

问题

Autoform 生成带有日期的表单。该表单用作数组并使用引导模板,该模板为add 或remove 附加条目提供了一些+- 按钮。当我使用aldeed:autoform-bs-datepicker 时,表单中出现了一个奇怪的问题。如果您输入日期并在保存前点击+- 按钮,日期就会消失。如果你不使用autoform-bs-datepicker,这个问题就会消失。

请参阅下面的代码,如果有办法可以将示例发布到网上,请告诉我,我会做的。

路径:packages.js

twbs:bootstrap
aldeed:collection2
aldeed:autoform
rajit:bootstrap3-datepicker
aldeed:autoform-bs-datepicker

路径:Schemas.js

Classes = new Mongo.Collection("Classes");

var Schemas = {};

Schemas.DatesNotWorking = new SimpleSchema({
    name: {
        type: String,
        optional: true           
    },
    startDate: {
        type: Date,  
        optional: true,
        autoform: {
            type: "bootstrap-datepicker",
            "data-date-autoclose": "true",
            datePickerOptions: {
                format: "yyyy",
                startView: "years",
                minViewMode: "years"
            }
        }     
    },
    endDate: {
        type: Date,  
        optional: true,
        autoform: {
            type: "bootstrap-datepicker",
            "data-date-autoclose": "true",
            datePickerOptions: {
                format: "yyyy",
                startView: "years",
                minViewMode: "years"
            }
        }               
    }
});


Schemas.DatesWorking = new SimpleSchema({
    name: {
        type: String,
        optional: true           
    },
    startDate: {
        type: Date,  
        optional: true
    },
    endDate: {
        type: Date,  
        optional: true       
    }
});

Schemas.Subjects = new SimpleSchema ({
    datesNotWorking: {
        type: [Schemas.DatesNotWorking],
        optional: true
    },
    datesWorking: {
        type: [Schemas.DatesWorking],
        optional: true
    }
});


Classes.attachSchema(Schemas.Subjects);

路径:dateExample.html

<head>
  <title>dateExample</title>
</head>

<body>
  {{> dateExampleNotWorking}}


  {{> dateExampleWorking}}
</body>



<template name="dateExampleNotWorking">
    {{#autoForm collection="Classes" id="classesForm" type="update"}}

        {{> afQuickField name='datesNotWorking'}}

        <button type="submit" class="btn btn-primary submit">Update</button>

    {{/autoForm}}   

</template>




<template name="dateExampleWorking">
    {{#autoForm collection="Classes" id="classesForm" type="update"}}

        {{> afQuickField name='datesWorking'}}

        <button type="submit" class="btn btn-primary submit">Update</button>

    {{/autoForm}}   

</template>

【问题讨论】:

  • 使用 nitrous.io 进行免费部署(仅限 50 小时)
  • 这真的是一个答案。我的问题是关于社区使用的流星包。我原以为更多的开发人员会对修复这个错误感兴趣。我不是在寻找免费开发。
  • 我在评论中的意思是,尝试live it up online您的代码,以便我们查看错误/错误
  • 啊,好的,现在我明白了。给我一分钟
  • 去这里https://github.com/aldeed/meteor-autoform-bs-datepicker/,你会看到问题按钮,然后你会发现一个用于创建问题的新按钮。

标签: meteor meteor-autoform


【解决方案1】:

在您的packages.js 中首先添加 jQuery,然后添加 rajit:bootstrap3-datepicker

twbs:bootstrap
aldeed:collection2
aldeed:autoform
jquery
rajit:bootstrap3-datepicker
aldeed:autoform-bs-datepicker

【讨论】:

  • 感谢您的建议。 Jquery 已经作为标准的流星包安装在上面。我确实尝试删除它并将 jquery 文件放置在您建议的位置,同时删除并重新安装 rajit:bootstrap3-datepicker 但是它没有解决问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-03
  • 1970-01-01
  • 1970-01-01
  • 2023-03-25
  • 2013-08-22
  • 1970-01-01
相关资源
最近更新 更多