플러그인에서 렌더링 된 일부 렌더링 된 HTML에 선택한 날짜를 표시하기 위해 기존 datepicker 플러그인 (Pikaday)을 수정하려고합니다.).JavaScript :`return`이없는 메소드에서 값을 가져 오는 방법
다음 setDate 메서드/함수가 사용하려는 날짜 문자열을 반환한다는 것을 확인했지만이를 추출하여 내 함수에서 사용하는 방법을 잘 모르겠습니다.
setDate: function(date, preventOnSelect)
{
if (!date) {
this._d = null;
if (this._o.field) {
this._o.field.value = '';
fireEvent(this._o.field, 'change', { firedBy: this });
}
return this.draw();
}
if (typeof date === 'string') {
date = new Date(Date.parse(date));
}
if (!isDate(date)) {
return;
}
var min = this._o.minDate,
max = this._o.maxDate;
if (isDate(min) && date < min) {
date = min;
} else if (isDate(max) && date > max) {
date = max;
}
this._d = new Date(date.getTime());
setToStartOfDay(this._d);
this.gotoDate(this._d);
if (this._o.field) {
this._o.field.value = this.toString();
fireEvent(this._o.field, 'change', { firedBy: this });
//I want to return `this._o.field.value`
}
if (!preventOnSelect && typeof this._o.onSelect === 'function') {
this._o.onSelect.call(this, this.getDate());
}
}
나는 this._o.field.value
을 반환하려면 :
하여 setDate 방법은 다음과 같이 나타납니다.
아무도 내가 이것을 움켜 잡고 내 기능에서 사용할 수있는 방법을 알고 있습니까?
추신 : 저는 PHP OOP 배경에서 왔기 때문에 JS OOP에 대한 이해가 부족할 수 있습니다. 미안합니다. 내 HTML 렌더링 기능 : this._o.field.value
를 포함
renderHeading = function(instance, c, year, month, days)
{
var opts = instance._o;
var html = '<div class="pika-heading">';
html += '<h3 class="pika-heading-year">' + year + '</h3>';
html += '<h1 class="pika-heading-date">' + opts.i18n.weekdaysShort[day] + ', ' + opts.i18n.monthsShort[month] + '</h1>';
return html += '</div>';
}
: 항상 확인을한다. –