回答編集履歴

1

確認用追記

2018/11/06 08:45

投稿

x_x
x_x

スコア13749

test CHANGED
@@ -19,3 +19,87 @@
19
19
  ```
20
20
 
21
21
  選択個数が0個になったときになぜかonChangeが2回走るようなので注意
22
+
23
+
24
+
25
+ -- 確認用
26
+
27
+
28
+
29
+ ```HTML
30
+
31
+ <!DOCTYPE html>
32
+
33
+ <html>
34
+
35
+ <head>
36
+
37
+ <meta charset="UTF-8" />
38
+
39
+ <title>flatpickr</title>
40
+
41
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.2/flatpickr.min.css" />
42
+
43
+ </head>
44
+
45
+ <body>
46
+
47
+ <input class="flatpickr" />
48
+
49
+ <!--script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script-->
50
+
51
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.2/flatpickr.min.js"></script>
52
+
53
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.5.2/l10n/ja.js"></script>
54
+
55
+ <script>
56
+
57
+ const nextYear = '2019';
58
+
59
+ const nextMonth = '11';
60
+
61
+ const nextDay = '10';
62
+
63
+ let selectedDatesLength = 0;
64
+
65
+ const config = {
66
+
67
+ altInput: true,
68
+
69
+ altFormat: "d",
70
+
71
+ locale: "ja",
72
+
73
+ dateFormat: "Y/m/d",
74
+
75
+ mode: "multiple",
76
+
77
+ inline: true,
78
+
79
+ shorthandCurrentMonth: true,
80
+
81
+ altInputClass: "hidden-altInput",
82
+
83
+ minDate: '"' + nextYear + '/' + nextMonth + '"', //翌月のカレンダーだけ表示
84
+
85
+ maxDate: '"' + nextYear + '/' + nextMonth + '/' + nextDay + '"',
86
+
87
+ onChange: function (selectedDates, dateStr, instance) {
88
+
89
+ console.log(selectedDates.length - selectedDatesLength);
90
+
91
+ selectedDatesLength = selectedDates.length;
92
+
93
+ }
94
+
95
+ };
96
+
97
+ flatpickr('.flatpickr', config);
98
+
99
+ </script>
100
+
101
+ </body>
102
+
103
+ </html>
104
+
105
+ ```