LoginSignup
0
0

More than 1 year has passed since last update.

flatpickr を適用した mobile 側の input time で second(秒) の入力が消えない

Last updated at Posted at 2019-01-15

tl;dr

step="60" で回避したらいいんやで。

<input type="time" step="60">

事象

flatpickr version: 4.5.2

flatpickr 最強じゃんイエーイからの、スマホで time 入力しようとしたら enableSeconds: false を何度コンフィグしても、秒(もはやミリ秒まで)も入力させられる。そもそも enableSeconds はデフォルトで false なのに。

原因

ソースみたら setupMobile() 内で self.mobileInput.step = self.input.getAttribute("step") || "any"; してて全く enableSeconds なんか一切見てない。 step 設定してないと無理やり any られるってのがわかる。

      function setupMobile() {
        var inputType = self.config.enableTime ? self.config.noCalendar ? "time" : "datetime-local" : "date";
        self.mobileInput = createElement("input", self.input.className + " flatpickr-mobile");
        self.mobileInput.step = self.input.getAttribute("step") || "any";

解決

self.input.getAttribute("step") って書いてるので、 input に step を好きなように追加してやりゃおk。 input time の step は秒単位らしいから、分だけでいいなら step="60" しとく。

<input type="time" step="60">
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0