?
avatar brianteeman
brianteeman
15 Mar 2021

I don't know if this is a bug in joomla or in my brain

I have a form with a calendar field
I have javascript that does a calculation on the value of the field and inserts the value into a new field

The javascript is triggered by fieldname.addEventListener("change",

If I manually enter a date in the field then the javascript is triggered and everything is good
If I select a date with the datepicker then the javascript is never triggered (no console errors)

Is it me or is it a bug in the calendar field

avatar brianteeman brianteeman - open - 15 Mar 2021
avatar joomla-cms-bot joomla-cms-bot - change - 15 Mar 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 15 Mar 2021
avatar Fedik
Fedik - comment - 15 Mar 2021

that a bug,
if I right remember there was an issue about it (maybe for j3)

avatar Megh05
Megh05 - comment - 15 Mar 2021

@Fedik Yes rightly said; .addEventListner(), .triger() or change() are not currently working with jQuery. You can try by using .dispatchEvent() or .on() instead.

avatar brianteeman
brianteeman - comment - 15 Mar 2021

Glad to hear that its not my brain failure

avatar brianteeman
brianteeman - comment - 15 Mar 2021

@Megh05 no jquery is being used

avatar brianteeman
brianteeman - comment - 15 Mar 2021

@Fedik any ideas how to fix it?

avatar Fedik
Fedik - comment - 15 Mar 2021

Try like in this comment #17515 (comment)

but like this:
in calendar.js:

this.inputField.dispatchEvent(new CustomEvent('change', {bubbles: true, cancelable: true}));

then in your code you should be able to use:

yourField.addEventListener("change", ...

I not tested, in theory should work

avatar brianteeman
brianteeman - comment - 15 Mar 2021

Thanks I will take a look tonight

avatar Fedik
Fedik - comment - 15 Mar 2021

btw, the Issue from 2017,
well, that need to fix someday ?

avatar richard67
richard67 - comment - 15 Mar 2021

btw, the Issue from 2017,
well, that need to fix someday ?

I suggest we do it in 2023 ?

avatar brianteeman
brianteeman - comment - 15 Mar 2021

@Fedik it works!!!!

I am not going to submit a PR for this as I would probably put it in the wrong place etctetc and it will be quicker for you to add the oneliner than for us to go back and fro discussing changes that I dont understand

avatar Fedik
Fedik - comment - 20 Mar 2021

please test #32755

avatar alikon alikon - change - 20 Mar 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-03-20 09:21:58
Closed_By alikon
avatar alikon alikon - close - 20 Mar 2021
avatar alikon
alikon - comment - 20 Mar 2021

closing as we have a pr #32755

Add a Comment

Login with GitHub to post a comment