【发布时间】: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/,你会看到问题按钮,然后你会发现一个用于创建问题的新按钮。