?
avatar MatthewDaggitt
MatthewDaggitt
29 Jan 2016

When the default calendar widget is used to choose a date, the "change" event for the attached input field is not fired.

Steps to reproduce the issue

Create a field of type="calendar" in an admin form. Then run the following script to attach the function to catch the "change" event.

var calendar = jQuery(...);
calendar.change(function() {
    console.log("hi");
});

Expected result

When typing in the box or selecting the date from the calendar widget with the mouse, the string "hi" should be logged to the console.

screen shot 2016-01-29 at 13 33 26

Actual result

The string "hi" is only logged to the console when typing in the box, not when a date on the calendar widget is clicked.

System information (as much as possible)

Joomla 3.4!

Additional comments

This is really irritating if you want to write some custom validation for two dates that depend on each other (e.g. start date and end date).

avatar MatthewDaggitt MatthewDaggitt - open - 29 Jan 2016
avatar flash1452
flash1452 - comment - 4 Mar 2016

@MatthewDaggitt I think a better way to trigger this event will be to use datepicker of Jquery
http://stackoverflow.com/questions/11610797/trigger-function-when-date-is-selected-with-jquery-ui-datepicker

avatar brianteeman brianteeman - change - 10 Mar 2016
Category JavaScript Fields JavaScript
avatar MatthewDaggitt
MatthewDaggitt - comment - 16 Mar 2016

@flash1452 Thanks for your reply. Unfortunately (correct me if I'm wrong) I don't think the Joomla calendar widget uses the JQuery datepicker. Certainly jQuery("#form_startdate").datepicker is undefined.

Even if it does, shouldn't the Joomla calendar widget implement the standard event API?

avatar flash1452
flash1452 - comment - 16 Mar 2016

@MatthewDaggitt If the standard event API is not working in this case then I think we can go for this little hack if it is possible.

avatar Ruchiranga
Ruchiranga - comment - 25 Mar 2016

Hi,
I am trying to reproduce the issue but I don't have a clear idea on how to perform "Create a field of type="calendar" in an admin form".
Could you please provide a detailed set of steps?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9025.

avatar MatthewDaggitt
MatthewDaggitt - comment - 25 Mar 2016

So in admin/models/forms/event.xml I have:

<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset>
     ...
     <field 
        name="startdate" 
        type="calendar" 
        label="Start date" 
        default="2016-01-01"
        description="The date the event starts on? (in the form YYYY-MM-DD)"
        format="%Y-%m-%d"
        class="validate-startdate"
     />
     ...
</fieldset>
</form>

and in admin/views/event/tmpl/edit.php I have:

...
<script type="text/javascript">
    var calendar = jQuery('.validate-startdate');
    calendar.change(function() {
        console.log("hi");
    });
</script>

Is there anything else you need? If needs be I can link the full code of the entire component...


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9025.

avatar brianteeman brianteeman - change - 9 Dec 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-12-09 13:06:29
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 9 Dec 2016

As the entire code for the calendar has been changed for 3.7 I am closing this. If you still have issues with the calendar code in 3.7 please open a new issue


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/9025.

avatar brianteeman brianteeman - edited - 9 Dec 2016
avatar brianteeman brianteeman - close - 9 Dec 2016

Add a Comment

Login with GitHub to post a comment