JS toggle class read/unread when clicking on vue component NotificationReadToggle.vue

This commit is contained in:
2022-01-13 18:56:07 +01:00
parent d7d7fb5693
commit 819017112d
4 changed files with 18 additions and 3 deletions

View File

@@ -26,13 +26,25 @@ window.addEventListener('DOMContentLoaded', function (e) {
buttonNoText: 'false' === el.dataset.buttonText,
showUrl: el.dataset.showButtonUrl,
isRead: 1 === +el.dataset.notificationCurrentIsRead,
container: el.dataset.container
}
},
computed: {
getContainer() {
return document.getElementById(this.container);
}
},
methods: {
onMarkRead() {
if (null !== this.getContainer) {
this.getContainer.classList.replace('read', 'unread');
}
this.isRead = false;
},
onMarkUnread() {
if (null !== this.getContainer) {
this.getContainer.classList.replace('unread', 'read');
}
this.isRead = true;
},
}
@@ -40,4 +52,4 @@ window.addEventListener('DOMContentLoaded', function (e) {
.use(i18n)
.mount(el);
});
})
});