This Rails 7 application will demonstrate behaviour when Stimulus is binding twice on new page depending on method used in previous request. If there is a redirect after GET request - then Stimulus will connect to element on new page, disconnect and connect again. But if I change method to POST request and do the same redirect - then I'm only getting single "connect". Please notice that I've opted-out of caching (in layout's head).
Test scenario
- Open http://localhost:3000/home/show
- Open web developer console to
- Click "Test GET" and observe that you'll see - "connect", "disconnect" and "connect" logs
- Go back and click "Test POST" and observe that you'll only see single "connect".