我想將CountdownTimer設置爲用戶選擇的特定日期。我在流星集合從Meteor Collection獲取CountdownTimer的數據
Template.addDate.events({
'submit form':function(event){
var closeDate = $('[name="date"]').val();
Date.insert({
closeDateDB: closeDate,
)};
}
});
保存現在我想從收集得到這個數據,並設定新的結束時間在我的定時器來此採摘的日期。
Meteor.startup(function() {
var endtime = Data.findOne(???);
timeinterval = setInterval(function() {
Meteor.call("getCurrentTime", function (error, result) {
Session.set("time", result);
var t = getTimeRemaining(endtime);
Session.set("t", t);
});
}, 1000);
});
我如何在我的數據庫中獲取插入日期並將其用於我的計時器?如何填寫「???」在
Data.findOne(???);
EDIT___
我嘗試定義什麼更好我想要實現。 如果用戶進入該網站,他應填寫表格。就像這樣:
Template.addQuestions.events({
'submit form':function(event){
event.preventDefault();
var questionText = $('[name="questionName"]').val();
var categoryText = $('[name="categoryName"]').val();
var closeDate = $('[name="date"]').val();
Questions.insert({
closeDateDB: closeDate,
categoryDB1: categoryText,
questionDB: questionText,
createdAt: new Date(),
}, function (error,results){
Router.go('decision', {_id:results});
}
正如你所看到的,我得到了closeDateDB,用戶可以通過datepicker選擇一個日期。我用tsega:bootstrap3-datetimepicker
。在此之後,用戶被重定向到一個新創建的網站。
在這個新的網站,我想獲得例如closeDate 「2015年12月24日」我countdowntimer作爲Meteor.startup();
結束時間計數器應該從currentTime的,實際的日期/時間算提交表單時,直到用戶在表單中輸入的closeDate日期/時間。當實際日期/時間>closeDate
時,應關閉創建的網站,並將用戶重定向到其他網頁。
我不知道大局觀做法是什麼,但你有沒有見過這個包:[mizzao:時間同步(https://atmospherejs.com/mizzao/timesync) ? – ejb
你想找到哪個文件不清楚這個問題。你能否添加更多關於你想達到的信息? –