@@ -30,6 +30,22 @@ const EVENT_SUBMIT = `${EVENT_ROOT}:submit`;
30
30
*/
31
31
const EVENT_CHANGE = `${ EVENT_ROOT } :change` ;
32
32
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
+
33
49
// ////////////////////////////////////////////////////////////////////////////
34
50
35
51
/**
@@ -62,6 +78,14 @@ export default class Form extends View {
62
78
throw new Error ( 'Form: Missing form element' ) ;
63
79
}
64
80
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
+
65
89
// Apply custom Bootstrap validation to form
66
90
this . $form . addEventListener ( 'submit' , ( evt ) => this . $submit ( evt ) ) ;
67
91
this . $form . addEventListener ( 'change' , ( evt ) => this . $change ( evt ) ) ;
0 commit comments