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,
|
||||
LocalDatetime
|
||||
},
|
||||
|
||||
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")
|
||||
|
||||
if (modalOpen) {
|
||||
const modal = modalOpen.getAttribute("data-modal")
|
||||
this.openModal(modal)
|
||||
|
@ -2,9 +2,11 @@ export default {
|
||||
methods: {
|
||||
closeModal: function(name) {
|
||||
this.modals[name] = false
|
||||
this.$emit('modalOpen', false)
|
||||
},
|
||||
openModal: function (name) {
|
||||
this.modals[name] = true
|
||||
this.$emit('modalOpen', true)
|
||||
}
|
||||
},
|
||||
data: function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user