Skip to content

Commit 0ea538f

Browse files
committed
Added show hide events for form and bumped to v0.0.46
1 parent 154524e commit 0ea538f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

js/form.js

+24
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ const EVENT_SUBMIT = `${EVENT_ROOT}:submit`;
3030
*/
3131
const 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));

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@djthorpe/js-framework",
3-
"version": "0.0.45",
3+
"version": "0.0.46",
44
"description": "Javascript Framework",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)