MediaWiki:Common.js
From hmis
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* 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 );
});