feature: update sib-display on form save

This commit is contained in:
Jean-Baptiste Pasquier 2019-06-05 13:26:10 +02:00
parent 89db25fa85
commit de6217dd2d
No known key found for this signature in database
GPG Key ID: F2702E6D22ED4D62

View File

@ -3,9 +3,9 @@ document.addEventListener('DOMContentLoaded', function (event) {
const rightMenus = Array.from(document.querySelectorAll('nav.jsRightMenu'));
const viewsContainer = Array.from(document.querySelectorAll('.views-container'));
window.addEventListener('navigate', (event) => {
//- View change event
});
// window.addEventListener('navigate', (event) => {
// });
//- Toggle sub-menus
menuWrappers.forEach(menuWrapper => {
@ -25,4 +25,15 @@ document.addEventListener('DOMContentLoaded', function (event) {
})
});
//- Watch every sib-forms & update data-src of linked sib-display
document.querySelectorAll('sib-form[data-src], sib-form[bind-resource]').forEach(function(el) {
el.addEventListener("save", function() {
let dataSrc = el.getAttribute('data-src');
document.querySelectorAll('sib-display[data-src="'+dataSrc+'"]').forEach(function(e) {
e.setAttribute('data-src', dataSrc);
});
});
});
});