Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ And include the `<modals-container/>` component it in your project:
<modals-container/>
```

Alternatively, the modals container can be automatically appended to the document body once the plugin is loaded using `injectModalsContainer: true`:

```js
Vue.use(VModal, { dynamic: true, injectModalsContainer: true })
```

Call it (the first argument is the component definition, the second are component properties, the third modal parameters, and the fourth the modal event listeners):

```javascript
Expand Down
2 changes: 1 addition & 1 deletion src/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export default {
/**
* Returns class list for click outside overlay (background click)
*/
backgroundClickClass() {
backgroundClickClass () {
return ['v--modal-background-click']
},
/**
Expand Down
4 changes: 2 additions & 2 deletions src/ModalsContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default {
methods: {
add (modal, params, config, events) {
let id = this.uid++
config = config ? Object.assign({}, config) : {};
config = config ? Object.assign({}, config) : {}
if (!config.name) {
config.name = '_dynamic-modal-' + id;
config.name = '_dynamic-modal-' + id
}
this.modals.push({
id: id,
Expand Down
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const Plugin = {
* Registration of <ModalsContainer/> component
*/
if (options.dynamic) {
Vue.component('modals-container', ModalsContainer)
if (options.injectModalsContainer) {
const modalsContainer = document.createElement('div')
document.body.appendChild(modalsContainer)
new Vue({ render: h => h(ModalsContainer) }).$mount(modalsContainer)
} else {
Vue.component('modals-container', ModalsContainer)
}
}
}
}
Expand Down