Skip to content

Commit 25289cd

Browse files
committed
Solved problem connected with v-model
1 parent 43f34a6 commit 25289cd

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"name": "vue-functional-calendar",
88
"description": "Lightweight, high-performance calendar component based on Vue.js",
9-
"version": "2.8.77",
9+
"version": "2.8.79",
1010
"license": "MIT",
1111
"repository": {
1212
"type": "git",

src/Demo.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<FunctionalCalendar class="demo-calendar dateRangeInputs"
55
ref="demoCalendar1"
66
v-model="demoCalendar1"
7-
:is-modal="false"
7+
:is-modal="true"
88
:is-date-range="true"
99
:is-multiple="true"
1010
:isLayoutExpandable="true"
@@ -213,7 +213,8 @@
213213
components: {FunctionalCalendar},
214214
data() {
215215
return {
216-
demoCalendar1: {},
216+
demoCalendar1: {
217+
},
217218
events: [
218219
{
219220
id: 1,

src/components/FunctionalCalendar.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,10 @@
236236
237237
// Reacts to external selected dates
238238
this.$watch('value', function (value) {
239-
this.calendar = value;
240-
}, {deep: true});
239+
if (value.hasOwnProperty('dateRange')) {
240+
this.calendar = value;
241+
}
242+
}, {immediate: true, deep: true});
241243
242244
this.$watch('showCalendar', function (value) {
243245
if (value)
@@ -566,12 +568,17 @@
566568
this.showCalendar = false;
567569
}
568570
} else if (this.fConfigs.isMultipleDatePicker) {
569-
if (this.calendar.selectedDates.find(date => date.date === item.date)) {
571+
if (this.calendar.hasOwnProperty('selectedDates') && this.calendar.selectedDates.find(date => date.date === item.date)) {
570572
let dateIndex = this.calendar.selectedDates.findIndex(date => date.date === item.date);
571573
this.calendar.selectedDates.splice(dateIndex, 1);
572574
} else {
573575
let date = Object.assign({}, this.defaultDateFormat);
574576
date.date = item.date;
577+
578+
if(!this.calendar.hasOwnProperty('selectedDates')) {
579+
this.calendar.selectedDates = [];
580+
}
581+
575582
this.calendar.selectedDates.push(date);
576583
}
577584
@@ -609,7 +616,7 @@
609616
if (this.calendar.selectedDate === day.date)
610617
day.isMarked = true;
611618
} else if (vm.fConfigs.isMultipleDatePicker) {
612-
if (vm.calendar.selectedDates.find(date => date.date === day.date))
619+
if (vm.calendar.hasOwnProperty('selectedDates') && vm.calendar.selectedDates.find(date => date.date === day.date))
613620
day.isMarked = true;
614621
} else {
615622
day.isMouseToLeft = false;
@@ -1052,7 +1059,7 @@
10521059
classes.push('vfc-end-marked');
10531060
}
10541061
1055-
if (day.date === this.calendar.selectedDate || this.calendar.selectedDates.find(sDate => sDate.date === day.date)) {
1062+
if (day.date === this.calendar.selectedDate || (this.calendar.hasOwnProperty('selectedDates') && this.calendar.selectedDates.find(sDate => sDate.date === day.date))) {
10561063
classes.push('vfc-borderd')
10571064
}
10581065

0 commit comments

Comments
 (0)