Common.js: Difference between revisions
From hmis
No edit summary |
No edit summary Tag: Reverted |
||
| Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// Example of a DateTimeInputWidget | |||
var dateTimeInput = new mw.widgets.datetime.DateTimeInputWidget({ | |||
// Configuration options can go here | |||
type: 'datetime', // Can be 'date', 'time', or 'datetime' | |||
// Other options like 'utc' (boolean) or 'timezone' (string) | |||
}); | |||
// Append the widget to an element in your HTML form | |||
$( 'body' ).append( dateTimeInput.$element ); | |||
// Accessing the value | |||
dateTimeInput.on( 'change', function () { | |||
var dateValue = dateTimeInput.getValue(); | |||
console.log( 'Selected date and time: ' + dateValue ); | |||
}); | |||
Revision as of 08:36, November 4, 2025
/* Any JavaScript here will be loaded for all users on every page load. */
// Example of a DateTimeInputWidget
var dateTimeInput = new mw.widgets.datetime.DateTimeInputWidget({
// Configuration options can go here
type: 'datetime', // Can be 'date', 'time', or 'datetime'
// Other options like 'utc' (boolean) or 'timezone' (string)
});
// Append the widget to an element in your HTML form
$( 'body' ).append( dateTimeInput.$element );
// Accessing the value
dateTimeInput.on( 'change', function () {
var dateValue = dateTimeInput.getValue();
console.log( 'Selected date and time: ' + dateValue );
});