Skip to content

InputfieldDatetime does not trigger change event on <input> #2062

@BernhardBaumrock

Description

@BernhardBaumrock

I'm working on an auto-save feature for my current project. I check for changes in the page editor like this:

document.addEventListener("input", (e) => this.registerChange(e.target));
document.addEventListener("change", (e) => this.registerChange(e.target));

Some fields like TinyMCE need special treatment, but I also realised that date inputs also do not trigger a save and I was wondering why.

This is the fix that makes it work:

// Monitor datepicker changes
$(document).on("change", ".InputfieldDatetimeDatepicker", (e) =>
  this.registerChange(e.target)
);

But I think it would be better to also trigger the change event in InputfieldDatetime.js:

if (pickerVisible) {
	$datepicker.on("change", function (e) {
		var d = $datepicker.datepicker("getDate");
		var str = $.datepicker.formatDate(dateFormat, d);

		// add .trigger('change') here
		$t.val(str).trigger("change");
	});
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions