diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fe8dc..4495e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Next +* Allow multiple slot finder instances on one site (#383421) ## [1.4.5] - 08.05.2024 diff --git a/content-elements/base/slot-finder/prototype/slot-finder.js b/content-elements/base/slot-finder/prototype/slot-finder.js index f82ae9f..485fcfc 100644 --- a/content-elements/base/slot-finder/prototype/slot-finder.js +++ b/content-elements/base/slot-finder/prototype/slot-finder.js @@ -29,34 +29,35 @@ import { initDayView, initWeekView } from "../src/slot/slot.js"; * @property {Observable} selectedSlot */ -/** @type {Model} */ -const model = { - locale: '', - url: '', - selectedDate: Observable(new Date()), - slots: Observable([]), - selectedSlot: Observable(null), -}; - Alpine.data('slotFinder', () => ({ + + /** @type {Model} */ + model: { + locale: '', + url: '', + selectedDate: Observable(new Date()), + slots: Observable([]), + selectedSlot: Observable(null), + }, + init() { - model.locale = document.documentElement.lang.slice(0, 2) ?? 'de'; - model.url = this.$el.dataset.bsiUrl ?? ''; + this.model.locale = document.documentElement.lang.slice(0, 2) ?? 'de'; + this.model.url = this.$el.dataset.bsiUrl ?? ''; }, initCalendar() { - initCalendar(model, this.$el); + initCalendar(this.model, this.$el); }, initDayView() { - initDayView(model, this.$el, this.$refs.noSlotsText, this.$refs.chooseAnotherDayText); + initDayView(this.model, this.$el, this.$refs.noSlotsText, this.$refs.chooseAnotherDayText); }, initWeekView() { - initWeekView(model, this.$el, this.$refs.noSlotsText, this.$refs.chooseAnotherDayText); + initWeekView(this.model, this.$el, this.$refs.noSlotsText, this.$refs.chooseAnotherDayText); }, initSummary() { - initSummary(model, this.$el, this.$refs.bookButton); + initSummary(this.model, this.$el, this.$refs.bookButton); }, }));