diff --git a/README.md b/README.md
index c767b0d..7ff0730 100644
--- a/README.md
+++ b/README.md
@@ -177,6 +177,19 @@ this.$modal.show(MyComponent, {
})
```
+Other than defining the `name` modal parameter, it's also possible to close dynamic modals emitting a `'close'` event:
+
+```javascript
+this.$modal.show({
+ template: `
+
+
This is created inline
{{ text }}
@@ -243,9 +243,19 @@ export default {
},
showDynamicComponentModalWithModalParams () {
- this.$modal.show(CustomComponentModal, {
- text: 'This text is passed as a property'
- }, {
+ this.$modal.show({
+ template: `
+
+
+
+
+ `,
+ methods: {
+ closeByName() { this.$modal.hide('dynamic-modal'); },
+ closeByEvent() { this.$emit('close'); },
+ }
+ }, null, {
+ name: 'dynamic-modal',
resizable: true,
adaptive: true,
draggable: true,
diff --git a/demo/client_side_rendering/src/components/CustomComponentModal.vue b/demo/client_side_rendering/src/components/CustomComponentModal.vue
index ac4b322..d0c3d11 100644
--- a/demo/client_side_rendering/src/components/CustomComponentModal.vue
+++ b/demo/client_side_rendering/src/components/CustomComponentModal.vue
@@ -1,5 +1,5 @@
-
+
This is a custom component
{{ text }}
diff --git a/src/ModalsContainer.vue b/src/ModalsContainer.vue
index 479dedd..b721f7c 100644
--- a/src/ModalsContainer.vue
+++ b/src/ModalsContainer.vue
@@ -3,11 +3,14 @@
-
+
@@ -25,16 +28,18 @@ export default {
methods: {
add (modal, params, config) {
let id = this.uid++
- let name = '_dynamic-modal-' + id
+ config = config || {};
+ if (!config.name) {
+ config.name = '_dynamic-modal-' + id;
+ }
this.modals.push({
id: id,
- name: name,
component: modal,
params: params || {},
config: config || {}
})
this.$nextTick(() => {
- this.$modal.show(name)
+ this.$modal.show(config.name)
})
},
remove (id) {