Topic: DateTimePicker Error

jamie priority asked 2 years ago


I am using the datetimepicker. i have it setting the date via javascript, but when i change the date on the screen i get the following error:

index.js:312 Uncaught TypeError: Cannot read properties of null (reading 'defaultPrevented') at Xm._openDatePicker (index.js:312:59) at HTMLInputElement. (index.js:232:12) at HTMLDivElement.n (event-handler.js:119:21)

My data look like arr = { "id": "7", "title": "First Test", "content": "What is Lorem Ipsum?", "ispublished": "1", "publisheddate": "2022-02-24 11:43:00", }; I am also using moment.js to format the date and time

const dateTime = document.querySelector('.datetimepicker') mdb.Datetimepicker.getInstance(dateTime).dispose() const myDatetimepicker = new mdb.Datetimepicker(document.querySelector('.pubdatetime'), { defaultDate: moment(arr.publisheddate).format('DD/MM/YYYY'), defaultTime: moment(arr.publisheddate).format('hh:mm A') });


Michał Duszak staff commented 2 years ago

Hello, could you please reproduce your issue in a snippet with MDB Snippets? Here is the link: https://mdbootstrap.com/snippets/ It will be easier to debug your issue, as we will be referencing the same environment.


jamie priority commented 2 years ago

ok,see snippet you will see the above error from the console.


Grzegorz Bujański staff answered 2 years ago


It is an error on our side related to component reinitialization. I understand that reinitialization with js code is important to you in this case and you cannot use the data attributes? If so, I have a workaround for this error for you: https://mdbootstrap.com/snippets/standard/grzegorz-bujanski/3715724#html-tab-view


Andrew Sonnenschein priority commented 2 years ago

Is this something that will be addressed at some point? Its not great to have to place any dynamic loaded html markup that includes .form-outline in JS like you did in the workaround.


Grzegorz Bujański staff commented 2 years ago

Yes. I added a task to our to-do list to fix this



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.2
  • Device: pc
  • Browser: chrome
  • OS: win11
  • Provided sample code: No
  • Provided link: No