Calendar ignoring javascript instance


Topic: Calendar ignoring javascript instance

Macjohn asked 4 years ago

Expected behavior Ability to instantiate calendar via javascript

Actual behavior No calendar via javascript. Canlendar only showing if I use data-mdb attributes.

Resources (screenshots, code snippets etc.)

This works:

<div 
     class='calendar' 
     id='calendar'
     data-mdb-monday-first='true'
 ></div>

This does not work.

<div id='calendar'></div>

with this javascript:

const calendarElement = document.getElementById('calendar');
const instance = Calendar.getInstance(calendarElement, {
    mondayFirst: true,
});
instance.next();

As soon as I add the class 'calendar' it works, but it is ignoring the javascript options. The javascript is loaded, and it is loaded after mdb. Can you help?


Grzegorz Bujański staff answered 4 years ago

Thanks for reporting a bug. We'll fix it. As a workaround, use this code:

<div id='calendar'></div>

const calendarElement = document.getElementById('calendar');
calendarElement.classList.add('calendar');
const instance = new Calendar(calendarElement, {
  mondayFirst: true;
});

btgdev pro premium priority commented a year ago

Hello! Has there been a resolution for this? Your workaround works fine, and I'm fine with using the workaround, but I wanted to make sure I wasn't otherwise causing a problem by continuing to use the workaround.


kpienkowska staff commented a year ago

We did not change that. This method is still valid.


Macjohn answered 4 years ago

OK great - thanks. That works for now.


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: 3.2.0
  • Device: Any
  • Browser: Any
  • OS: Any
  • Provided sample code: No
  • Provided link: No
Tags