Emit and respond to a modalOpen event, which conditionally adds a class to the body
This commit is contained in:
parent
c1e6bc0f84
commit
27b03eea04
10
js/index.js
10
js/index.js
@ -41,8 +41,18 @@ const app = new Vue({
|
|||||||
CcpoApproval,
|
CcpoApproval,
|
||||||
LocalDatetime
|
LocalDatetime
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
|
this.$on('modalOpen', isOpen => {
|
||||||
|
if (isOpen) {
|
||||||
|
document.body.className += ' modal-open'
|
||||||
|
} else {
|
||||||
|
document.body.className = document.body.className.replace(' modal-open', '')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const modalOpen = document.querySelector("#modalOpen")
|
const modalOpen = document.querySelector("#modalOpen")
|
||||||
|
|
||||||
if (modalOpen) {
|
if (modalOpen) {
|
||||||
const modal = modalOpen.getAttribute("data-modal")
|
const modal = modalOpen.getAttribute("data-modal")
|
||||||
this.openModal(modal)
|
this.openModal(modal)
|
||||||
|
@ -2,9 +2,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
closeModal: function(name) {
|
closeModal: function(name) {
|
||||||
this.modals[name] = false
|
this.modals[name] = false
|
||||||
|
this.$emit('modalOpen', false)
|
||||||
},
|
},
|
||||||
openModal: function (name) {
|
openModal: function (name) {
|
||||||
this.modals[name] = true
|
this.modals[name] = true
|
||||||
|
this.$emit('modalOpen', true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function() {
|
data: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user