made all components common

This commit is contained in:
Mark Gregory
2026-07-02 09:32:00 +01:00
parent fbf7a1fc6b
commit b8a9ab2e24
5 changed files with 162 additions and 94 deletions
+23
View File
@@ -136,6 +136,27 @@ function renderWmsCharts() {
});
}
function livewireComponentFor(element) {
const componentRoot = element.closest('[wire\:id]');
if (!componentRoot || !window.Livewire) {
return null;
}
return window.Livewire.find(componentRoot.getAttribute('wire:id'));
}
function setLivewireProperty(element, model, value) {
const component = livewireComponentFor(element);
if (!component || !model) {
return;
}
component.set(model, value === '' ? null : value);
}
/**
* Initialise Select2 controls.
*
@@ -168,6 +189,8 @@ function initialiseSelect2() {
$select.off('change.select2-livewire');
$select.on('change.select2-livewire', function () {
setLivewireProperty(this, this.dataset.wireModel, $select.val());
this.dispatchEvent(
new Event('change', {
bubbles: true,