Topic: Click on calendar Day in Month view.

Onnela free asked 3 years ago


Expected behavior Hi I would like to show the number of events an a particular day in a Month view, (there can be a lot). Then on click() trigger a function that is loading a list with all events that day.

Actual behavior Can not find out how to catch the click() event on a day....

Resources (screenshots, code snippets etc.)


Dawid Wajszczuk staff answered 3 years ago


Hi,

You can try to add this JS code:

document.querySelectorAll('#calendar .month td').forEach((day)=>{day.addEventListener('click', (e)=>{
  alert('Click event :)')
})})

Here is the snippet with this solution: https://mdbootstrap.com/snippets/standard/d-wajszczuk/3247858#js-tab-view. I hope this will solve your issue.

Keep coding,
Dawid



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: Free
  • Premium support: No
  • Technology: MDB Standard
  • MDB Version: MDB5 3.8.0
  • Device: IntelliJ
  • Browser: Firefox Dev
  • OS: Mac
  • Provided sample code: No
  • Provided link: No