datetimepicker is not a function

У меня есть некоторые элементы, которые я добавляю динамически с помощью JQuery. Bootstrap Datepicker отлично работает на элементах ввода, которые уже присутствуют при загрузке страницы, но не работают с динамически добавленными элементами. Поэтому я попытался использовать функцию .on JQuery. Но я получаю следующее сообщение об ошибке, когда я устанавливаю код привязки datepicker в любом месте документа.

Ошибка:

Script

UPDATE:

Это не работает ни с одним элементом (datetimepicker не является функцией):

Это работает только с уже присутствующими элементами:

ОБНОВЛЕНИЕ 2: (щелкните внутри первого текстового поля, чтобы добавить новую строку сетки, нажмите внутри второй, чтобы увидеть календарь, который работает только в первой строке) https://jsfiddle.net/a8j30rcw/1/

Вы не должны пытаться прослушивать сборщик datetime на основе атрибута id . Причина в том, что добавление элементов динамически внутри страницы может создать более одного вхождения сборщика datetime w

с тем же id . Еще раз id имеет уникальность.

Используйте класс ( datetimepicker ) или некоторый HTML data-attribute , а затем прослушайте его. Поскольку событие обрабатывает динамические элементы, добавленные после загрузки страницы, вам вообще не нужно $(document).ready , хотя вы можете добавить его без каких-либо побочных эффектов.

Обновление: На click вы просто инициализировали сборщик каждый раз, когда нажимаете кнопку. Никогда не запускал метод show . Я проверяю, инициализирован ли выбор времени во время первого щелчка, если нет, я инициализирую его и покажу сборщик. В любом другом случае я оставляю код timepicker для выполнения своей работы, возвращаясь раньше.

I working with datetimepicker jquery ui, when code below html , datetimepicker is not displaying and when i inspect with firebug console it displayed an error «

and below is the code

Содержание

  1. 6 Answers 6
  2. Not the answer you’re looking for? Browse other questions tagged jquery-ui datetimepicker or ask your own question.
  3. Linked
  4. Related
  5. Hot Network Questions

6 Answers 6

Keep in mind, the jQuery UI’s datepicker is not initialized with datetimepicker(), there appears to be a plugin/addon here: http://trentrichardson.com/examples/timepicker/.

However, with just jquery-ui it’s actually initialized as $(«#example»).datepicker() . See jQuery’s demo site here: http://jqueryui.com/demos/datepicker/

To use the datetimepicker at the link referenced above, you will want to be certain that your scripts path is correct for the plugin.

I had the same problem with bootstrap datetimepicker extension. Including moment.js before datetimepicker.js was the solution.

For some reason this link solved my problem. I don’t know why tho..

NOTE: I am using Bootstrap 3 and Jquery 1.11.3

It’s all about the order of the scripts. Try to reorder them, place jquery.datetimepicker.js to be last of all scripts!

Not the answer you’re looking for? Browse other questions tagged jquery-ui datetimepicker or ask your own question.

Linked

Hot Network Questions

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

site design / logo © 2019 Stack Exchange Inc; user contributions licensed under cc by-sa 4.0 with attribution required. rev 2019.11.15.35459

I attempted to install Eonasdan’s Bootstrap DateTimePicker using webpack, but when I tried to use it, I got this error:

TypeError: $(…).datetimepicker is not a function

The problem is that datetimepicker is trying to use its own version of jquery, while the version of jquery used by everything else on the web application was a different version… So the function d > resolve section of my webpack.config.js

That’s it! (Credit to the folks on this GitHub issue for the fix!)

Источник: computermaker.info

Понравилась статья? Поделиться с друзьями:
Ок! Компьютер
Добавить комментарий