플러그인 개발을 통해 WordPress에서 Persian DatePicker를 구현하고 있습니다.
다음은 DatePicker의 라이브러리입니다.
http://babakhani.github.io/PersianWebToolkit/doc/datepicker/
하지만 브라우저에서 검사를 클릭하면 콘솔에 다음 오류가 표시됩니다.
Uncaught TypeError: Cannot read property 'event' of undefined
at persian-datepicker-0.4.5.min.js?ver=4.7.3:6
at persian-datepicker-0.4.5.min.js?ver=4.7.3:7
또한 JQuery Lib 이후에 js 라이브러리를로드합니다.
다음은 코드입니다.
jQuery(function ($) {
//Datepicker
if ($('.em-date-single, .em-date-range, #em-date-start').length > 0) {
em_setup_datepicker('body'); //Change class name to : .em-persian-date-start and .em-persian-date-end
$('.em-persian-date-start').pDatepicker({
persianDigit: true,
viewMode: false,
position: "auto",
autoClose: false,
format: false,
observer: false,
altField: '.em-date-input',
inputDelay: 800,
formatter: function (unixDate) {
var self = this;
var pdate = new persianDate(unixDate);
pdate.formatPersian = false;
return pdate.format(self.format);
},
altFormat: 'g',
altFieldFormatter: function (unixDate) {
var tzOffset = (new Date()).getTimezoneOffset() * 60000;
var self = this;
var thisAltFormat = self.altFormat.toLowerCase();
if (thisAltFormat === "gregorian" | thisAltFormat === "g") {
return new Date(unixDate - tzOffset).toISOString().substring(0, 10).replace('T', ' ');
}
if (thisAltFormat === "unix" | thisAltFormat === "u") {
return unixDate;
} else {
return new persianDate(unixDate).format(self.altFormat);
}
},
onSelect: function (unixDate) {
return this;
},
timePicker: {
enabled: true,
showSeconds: true,
showMeridian: true,
scrollEnabled: true
},
dayPicker: {
enabled: true,
scrollEnabled: true,
titleFormat: 'YYYY MMMM',
onSelect: function (selectedDayUnix) {
setEndDate(selectedDayUnix);
}
},
onlyTimePicker: false,
justSelectOnDate: true,
minDate: false,
maxDate: false
}); //init datePicker
}
});
WordPress에서는 $를 사용할 수 없으며 '$'대신 'jQuery'를 사용해야합니다.
예 :
var len = jQuery('.classname').length;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다