когда я установил aui datepicker с атрибутом maxDate календаря, иногда он не выбирался должным образом (хотя это немного странно). До полудня работало, потом нет.
Я использую Liferay 6.2 EE SP8. Используя ловушку, я пытаюсь изменить html\taglib\ui\input_date\page.jsp
<%
Calendar calendarCurrentDate = CalendarFactoryUtil.getCalendar();
%>
<%
if((PortalUtil.getPortletNamespace(PortletKeys.JOURNAL)).equals(namespace) && name.equals("expirationDate")){
%>
calendar: {
maximumDate: new Date(<%= calendarCurrentDate.get(Calendar.YEAR)+1 %>, <%= calendarCurrentDate.get(Calendar.MONTH) %>, <%= calendarCurrentDate.get(Calendar.DAY_OF_MONTH) %>)
},
<%
}
%>
Полный код средства выбора даты ниже
<aui:script use='<%= "aui-datepicker" + (BrowserSnifferUtil.isMobile(request) ? "-native" : StringPool.BLANK) %>'>
Liferay.component(
'<%= nameId %>DatePicker',
function() {
var datePicker = new A.DatePicker<%= BrowserSnifferUtil.isMobile(request) ? "Native" : StringPool.BLANK %>(
{
container: '#<%= randomNamespace %>displayDate',
mask: '<%= mask %>',
<%
if((PortalUtil.getPortletNamespace(PortletKeys.JOURNAL)).equals(namespace) && name.equals("expirationDate")){
%>
calendar: {
maximumDate: new Date(<%= calendarCurrentDate.get(Calendar.YEAR)+1 %>, <%= calendarCurrentDate.get(Calendar.MONTH) %>, <%= calendarCurrentDate.get(Calendar.DAY_OF_MONTH) %>)
},
<%
}
%>
on: {
disabledChange: function(event) {
var instance = this;
var container = instance.get('container');
var newVal = event.newVal;
console.log('disalbedChange'+newVal)
container.one('#<%= dayParamId %>').attr('disabled', newVal);
container.one('#<%= monthParamId %>').attr('disabled', newVal);
container.one('#<%= nameId %>').attr('disabled', newVal);
container.one('#<%= yearParamId %>').attr('disabled', newVal);
},
selectionChange: function(event) {
var instance = this;
var container = instance.get('container');
var date = event.newSelection[0];
console.log("event >"+event);
console.log("date >"+date);
if (date) {
container.one('#<%= dayParamId %>').val(date.getDate());
container.one('#<%= monthParamId %>').val(date.getMonth());
container.one('#<%= yearParamId %>').val(date.getFullYear());
}
}
},
popover: {
zIndex: Liferay.zIndex.TOOLTIP
},
trigger: '#<%= nameId %>'
}
);
datePicker.getDate = function() {
var instance = this;
var container = instance.get('container');
return new Date(container.one('#<%= yearParamId %>').val(), container.one('#<%= monthParamId %>').val(), container.one('#<%= dayParamId %>').val());
};
return datePicker;
}
);
Liferay.component('<%= nameId %>DatePicker');
Any help much appreciated. Is it anything related to timezone.
Попробуйте выбрать максимальную дату в качестве даты, затем, когда вы нажмете в поле ввода, введенное значение станет пустым. Этого не произойдет, если мы выберем другие даты до максимальной даты. Максимальная дата – один год с текущей даты
JS-скрипт
http://jsfiddle.net/uasvug1h/1/ (сплав 3 работал)
http://jsfiddle.net/btnkumar/uasvug1h/2/(сплав 2 не был работающий)
Как заставить это работать в сплаве 2