@@ -30,6 +30,22 @@ const EVENT_SUBMIT = `${EVENT_ROOT}:submit`;
3030 */
3131const EVENT_CHANGE = `${ EVENT_ROOT } :change` ;
3232
33+ /**
34+ * Form show event, which is emitted when the modal is shown.
35+ *
36+ * @event Form#form:show
37+ * @arg {Form} sender - The form that emitted the event.
38+ */
39+ const EVENT_SHOW = `${ EVENT_ROOT } :show` ;
40+
41+ /**
42+ * Form hide event, which is emitted when the modal is hidden.
43+ *
44+ * @event Form#form:hide
45+ * @arg {Form} sender - The form that emitted the event.
46+ */
47+ const EVENT_HIDE = `${ EVENT_ROOT } :hide` ;
48+
3349// ////////////////////////////////////////////////////////////////////////////
3450
3551/**
@@ -62,6 +78,14 @@ export default class Form extends View {
6278 throw new Error ( 'Form: Missing form element' ) ;
6379 }
6480
81+ // Apply show hide events to modal
82+ node . addEventListener ( 'show.bs.modal' , ( ) => {
83+ this . dispatchEvent ( EVENT_SHOW , this ) ;
84+ } ) ;
85+ node . addEventListener ( 'hidden.bs.modal' , ( ) => {
86+ this . dispatchEvent ( EVENT_HIDE , this ) ;
87+ } ) ;
88+
6589 // Apply custom Bootstrap validation to form
6690 this . $form . addEventListener ( 'submit' , ( evt ) => this . $submit ( evt ) ) ;
6791 this . $form . addEventListener ( 'change' , ( evt ) => this . $change ( evt ) ) ;
0 commit comments