KES free asked 3 years ago


Expected behavior Hi. I need close datepicker when target date is choosen. But user should click button 'ok' to confirm the choise. The event 'dateChange' is unuseful for this task. It fires only when button 'ok' is clicked. I think the confirm button 'ok' should be optional. Thanks. Actual behavior

Resources (screenshots, code snippets etc.)


Michał Duszak staff answered 2 years ago


Untill this option is not introduced, you can imitate click on Ok button upon selecting the day. Here's an example of this workaround:

https://mdbootstrap.com/snippets/standard/m-duszak/3542737#js-tab-view

const datepickerEl = document.querySelector('.datepicker')
const datepicker = mdb.Datepicker.getInstance(datepickerEl)

document.body.addEventListener('open.mdb.datepicker', () => {
    setTimeout(() => {
        document.body.addEventListener('click', handleDatePickerCellClick)
    }, 0)

})

function handleDatePickerCellClick(e, okBtn) {
    const isCellTargeted = e.target.classList.contains('datepicker-day-cell') || e.target.parentNode.classList.contains('datepicker-day-cell')
  if(isCellTargeted) {

  setTimeout(() => {
        const okBtn = document.querySelector('.datepicker-ok-btn')
        okBtn.click()
    document.body.removeEventListener('click', handleDatePickerCellClick)
  },50)
  }
}

Neo free answered 2 years ago


Also need auto-close option for datepicker plugin when a date was chosen by user, no need click the confirm button to close the popup.

Thx.


Michał Duszak staff answered 3 years ago


Hello, thank you for your feedback. We will discuss it in the frontend team.



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.9.0
  • Device: computer
  • Browser: firefox
  • OS: linux
  • Provided sample code: No
  • Provided link: No