- Description:
Javascript events for the
core_form
subsystem.
- Source:
- Since:
- 3.10
- Copyright:
- 2021 Huong Nguyen
- 2021 Huong Nguyen
- License:
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Javascript events for the core_form
subsystem.
Example
import {eventTypes as formEventTypes} from 'core_form/events';
document.addEventListener(formEventTypes.formSubmittedByJavascript, e => {
window.console.log(e.target); // The form that was submitted.
window.console.log(e.detail.skipValidation); // Whether form validation was skipped.
});
Members
(static, constant) eventTypes
- Description:
Events for
core_form
.
- Source:
Properties:
Name | Type | Description |
---|---|---|
formError |
String | See event:core_form/error |
formFieldValidationFailed |
String | |
formSubmittedByJavascript |
String | |
uploadChanged |
String | |
fieldStructureChanged |
String |
Events for core_form
.
(static, constant) types
- Description:
List of the events.
- Source:
- Deprecated:
- since Moodle 4.0. See eventTypes instead.
List of the events.
Methods
(static) notifyFieldStructureChanged(elementId) → {CustomEvent}
- Description:
Trigger an event to notify the field structure has changed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elementId |
string | The element which was changed |
Fires:
- event:fieldStructureChanged
Returns:
- Type
- CustomEvent
(static) notifyFormSubmittedByJavascript(form, skipValidation, fallbackHandled) → {CustomEvent}
- Description:
Trigger an event to indiciate that a form was submitted by Javascript.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
form |
HTMLElement | The form that was submitted |
skipValidation |
Boolean | Submit the form without validation. E.g. "Cancel". |
fallbackHandled |
Boolean | The legacy YUI event has been handled |
Fires:
- event:formSubmittedByJavascript
Returns:
- Type
- CustomEvent
(static) notifyUploadChanged(elementId) → {CustomEvent}
- Description:
Trigger an event to notify the file upload field has been changed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elementId |
string | The element which was changed |
Fires:
- event:uploadChanged
Returns:
- Type
- CustomEvent
(static) notifyUploadCompleted(elementId) → {CustomEvent}
- Description:
Trigger an event to indicate that an upload was completed.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elementId |
String | The element which was uploaded to |
Fires:
- event:uploadCompleted
Returns:
- Type
- CustomEvent
(static) notifyUploadStarted(elementId) → {CustomEvent}
- Description:
Trigger an event to indicate that an upload was started.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
elementId |
String | The element which was uploaded to |
Fires:
- event:uploadStarted
Returns:
- Type
- CustomEvent
(static) triggerUploadCompleted(elementId) → {CustomEvent}
- Description:
Trigger upload complete event.
- Source:
- Deprecated:
- Since Moodle 4.0 See notifyUploadCompleted
Parameters:
Name | Type | Description |
---|---|---|
elementId |
String |
Fires:
- event:uploadCompleted
Returns:
- Type
- CustomEvent
(static) triggerUploadStarted(elementId) → {CustomEvent}
- Description:
Trigger upload start event.
- Source:
- Deprecated:
- Since Moodle 4.0 See notifyUploadStarted
Parameters:
Name | Type | Description |
---|---|---|
elementId |
String |
Fires:
- event:uploadStarted
Returns:
- Type
- CustomEvent
(inner) changesMadeCheck(e)
- Description:
Prevent user navigate away when upload progress still running.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
e |
Event | The event |
(inner) notifyFieldValidationFailure(field, message) → {CustomEvent}
- Description:
Trigger an event to indicate that a form field contained an error.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
field |
HTMLElement | The field which failed validation |
message |
String | The message displayed |
Fires:
- event:formFieldValidationFailed
Returns:
- Type
- CustomEvent
(inner) notifyFormError(field) → {CustomEvent}
- Description:
Trigger an event to indicate that a form field contained an error.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
field |
HTMLElement | The form field causing the error |
Fires:
Returns:
- Type
- CustomEvent
Events
core_form/fieldStructureChanged
- Description:
An event triggered when a form field structure has changed.
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The form field that has changed |
Type:
- CustomEvent
core_form/fieldValidationFailed
- Description:
An event triggered upon form field validation failure.
- Source:
Properties:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
target |
HTMLElement | The field that failed validation |
||||||
detail |
object |
Properties
|
Type:
- CustomEvent
core_form/submittedByJavascript
- Description:
An event triggered when an mform is about to be submitted via javascript.
- Source:
Properties:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
target |
HTMLElement | The form that was submitted |
|||||||||
detail |
object |
Properties
|
Type:
- CustomEvent
core_form/uploadChanged
- Description:
An event triggered when a file upload field has been changed.
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The form field which was changed |
Type:
- CustomEvent
core_form/uploadCompleted
- Description:
An event triggered when an upload completes
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The location where the upload completed |
Type:
- CustomEvent
core_form/uploadStarted
- Description:
An event triggered when an upload is started
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The location where the upload began |
Type:
- CustomEvent
formError
- Description:
An event triggered when a form contains an error
- Source:
Properties:
Name | Type | Description |
---|---|---|
target |
HTMLElement | The form field which errored |
Type:
- CustomEvent