chore: Counter now embedded with Stimulus
Before this commit, Counter js was autonomous. Now it's registered like a controller in Stimulus.
This commit is contained in:
@@ -1,16 +1,3 @@
|
||||
// Entry point for the build script in your package.json
|
||||
import "@hotwired/turbo-rails"
|
||||
import "./controllers"
|
||||
import Counter from "./components/counter"
|
||||
|
||||
// Initialize counters when DOM is ready
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const counters = document.querySelectorAll('.counter')
|
||||
counters.forEach(counter => new Counter(counter))
|
||||
})
|
||||
|
||||
// Re-initialize counters on Turbo page loads
|
||||
document.addEventListener('turbo:load', () => {
|
||||
const counters = document.querySelectorAll('.counter')
|
||||
counters.forEach(counter => new Counter(counter))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user