0
我實現波斯的DatePicker在WordPress通過建立一種插件無法讀取的不確定
這裏屬性「事件」是的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的庫後加載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
}
});
是否'$ length'不是返回0。? – Justinas
是的,它按預期返回1 – Adnan