Meteor 处理重新渲染和事件
我在代码中使用meteorite插件pickadate(打包的jQuery插件),在处理会话、重新渲染和显示日历时遇到了问题Meteor 处理重新渲染和事件,meteor,Meteor,我在代码中使用meteorite插件pickadate(打包的jQuery插件),在处理会话、重新渲染和显示日历时遇到了问题 Template.datePicker.rendered = function() { var template = this; var checkOut = $('#checkOut').pickadate({ weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], format: 'dd/mm/
Template.datePicker.rendered = function() {
var template = this;
var checkOut = $('#checkOut').pickadate({
weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
format: 'dd/mm/yyyy',
today: '',
clear: '',
onClose: function(e) {
Session.set('openEndDate', false);
setDates(this, true);
getNights(checkInPicker, this);
}
});
var checkOutPicker = $('#checkOut').pickadate('picker');
var checkIn = $('#checkIn').pickadate({
weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
format: 'dd/mm/yyyy',
min: true,
today: '',
clear: '',
onClose: function(e) {
var year = this.get('select').year,
month = this.get('select').month,
date = this.get('select').date;
if (this.get()) {
checkOutPicker.set({
'min': [year,month,date+1],
'max': [year,month,date+28]
});
setDates(this);
Session.set('openEndDate', true);
};
}
});
var checkInPicker = $('#checkIn').pickadate('picker');
this.tCheckIn = checkInPicker;
this.tCheckOut = checkOutPicker;
if(Session.get('openEndDate')) {
this.tCheckOut.open();
}
}
我有一个名为datepicker的模板,它显示两个表,其中包含用于以dd/mm/yyyy格式显示日期的输入框,还有一个日历显示区域,用于以更直观的格式显示日期
<template name="datePicker">
<div class="dates">
<table class="dateTable">
<thead>
<tr>
<th><span class="checkDate"><input type="text" id="checkIn" name="checkIn" value="" placeholder="Check In"></span></th>
<th><span class="checkDate"><input type="text" id="checkOut" name="checkOut" value="" placeholder="Check Out"></span></th>
</tr>
</thead>
<tbody class="dateTableBody">
<tr>
<td id="startDate">
<span class="dayNum">{{startDateDayNum}}</span>
<div class="monthYear">
<span class="month">{{startDateMonth}}</span>
<span class="year">{{startDateYear}}</span>
</div>
<span class="day">{{startDateDayName}}</span>
</td>
<td id="endDate">
<span class="dayNum">{{endDateDayNum}}</span>
<div class="monthYear">
<span class="month">{{endDateMonth}}</span>
<span class="year">{{endDateYear}}</span>
</div>
<span class="day">{{endDate}}</span>
</td>
</tr>
</tbody>
</table>
<p class="welcomeRewards"><span class="wr">Welcome Rewards</span> <span class="nights">Collect <strong><b>1</b> nights</strong></span></p>
</div>
</template>
当前,单击签入输入框应显示pickadate日历,当选择日期时,将更新我的startDate会话并填充日历显示
我现在想要的是打开签出日历,但因为如果页面上没有显示,则页面已重新呈现
下面是我的呈现方法,显示了我如何实例化日历
Template.datePicker.rendered = function() {
var template = this;
var checkOut = $('#checkOut').pickadate({
weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
format: 'dd/mm/yyyy',
today: '',
clear: '',
onClose: function(e) {
Session.set('openEndDate', false);
setDates(this, true);
getNights(checkInPicker, this);
}
});
var checkOutPicker = $('#checkOut').pickadate('picker');
var checkIn = $('#checkIn').pickadate({
weekdaysShort: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
format: 'dd/mm/yyyy',
min: true,
today: '',
clear: '',
onClose: function(e) {
var year = this.get('select').year,
month = this.get('select').month,
date = this.get('select').date;
if (this.get()) {
checkOutPicker.set({
'min': [year,month,date+1],
'max': [year,month,date+28]
});
setDates(this);
Session.set('openEndDate', true);
};
}
});
var checkInPicker = $('#checkIn').pickadate('picker');
this.tCheckIn = checkInPicker;
this.tCheckOut = checkOutPicker;
if(Session.get('openEndDate')) {
this.tCheckOut.open();
}
}
meteor的工作方式是什么?尝试使用以下工具运行meteor:
meteor --release template-engine-preview-10.1
或者:
meteor update --release template-engine-preview-10.1
meteor
这将使用新模板引擎的最新预览版本,它对反应式呈现HTML具有更细粒度的控制,允许您正常使用大多数jQuery插件。新的模板引擎最终将合并到meteor 1.0之前的meteor core版本中,此时您可以执行以下操作:
meteor update
meteor
请注意,新引擎不需要(也不支持)
{{{constant}}
,{{{{constant}}}
,或者preserve
,因此如果您有任何问题,您需要删除它们。IMHO,“Meteor方法”只需使用,但是,即使没有Firefox的支持,我的项目也无法成功。那太糟糕了。谢谢你的指针。所以我正在努力解决这个问题,我也使用了Iron Router,所以我不得不使用shark分支来加载我的站点,现在我在Meteor UI中出现了template.base.js errors异常:错误:预期的有效属性名为“”、null或object。我想这是因为我使用的一些旧方法模板方法?好的,经过更多的重构后,我设法让事情重新开始,谢谢你,你知道什么时候发布吗?2014年初的某个时候