Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: MDBDatePicker bind event

Microtis free asked 5 years ago


Hello, I'm currently trying to bind an event on my datepicker to dispatch an update to my store

By calling the getValue, I can get the updated value but I cannot determine the source of this. Nothing happens when I call onChange or onInputChange... By the way, I use pure function to design the form component, that's why you will not see the this keyword on the example below.

Wich method of the Api should I call to get properly the event?

function handleChange(event) {
    const propName = event.target.name;
    let value = event.target.value;
    saison = { ...saison, [propName]: value };
    onSaisonChanged(saison);
}
let getPickerValue = (value) => {
    console.log(value);
}
<MDBDatePicker name="debutDate" keyboard value={saison.debutDate} 
onInputChange={event => handleChange(event)} />

<MDBDatePicker name="finDate" value={saison.finDate}
getValue={getPickerValue} />

Microtis free answered 5 years ago


Ok, creating a specific method foreach datepicker's getValue() on the form does the tricks but it doesn't look optimal.

it could be interesting to add the possibility to bind an event like Native React component.


Aliaksandr Andrasiuk staff commented 5 years ago

Hi,

We will add this kind of possibility.

Maybe you mentioned something else what should be fixed or should be added in the Datepicker component?

Best regards.


Microtis free commented 5 years ago

Nope, thanks for your support


Aliaksandr Andrasiuk staff answered 5 years ago


Hi,

onInputChange return event object if a keyboard was used. For example, you can set a cursor in the datepicker's input and try to press any key and then you will get the event object: onInputChange={(e) => console.log(e)}

Unfortunately, it's not fired when you change the value using mouse.

Thank you for the response.

We will invent something to make it possible.

Best regards.



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 React
  • MDB Version: 4.18.0
  • Device: pc
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No