|
import { Controller } from 'stimulus'; |
|
import { visit } from '@hotwired/turbo'; |
|
|
|
export default class extends Controller { |
|
count = 0; |
|
static targets = ['count']; |
|
|
|
increment() { |
|
this.count++; |
|
this.countTarget.innerText = this.count; |
|
|
|
if (this.count === 10) { |
|
visit('/you-won'); |
|
} |
|
} |
|
} |
See Code Block in Script
|
|
// ... lines 1 - 13
|
|
import { Modal } from 'bootstrap'; |
|
|
|
document.addEventListener('turbo:before-cache', () => { |
|
if (document.body.classList.contains('modal-open')) { |
|
const modal = Modal.getInstance(document.querySelector('.modal')); |
|
modal.hide(); |
|
} |
|
}); |
See Code Block in Script
|
|
// ... lines 1 - 13
|
|
import { Modal } from 'bootstrap'; |
|
|
|
document.addEventListener('turbo:before-cache', () => { |
|
if (document.body.classList.contains('modal-open')) { |
|
const modalEl = document.querySelector('.modal'); |
|
const modal = Modal.getInstance(modalEl); |
|
modalEl.classList.remove('fade'); |
|
modal._backdrop._config.isAnimated = false; |
|
modal.hide(); |
|
modal.dispose(); |
|
} |
|
}); |
See Code Block in Script
…data-turbo-temporary` to the dialog element, when I navigate to the page containing the modal via the back navigation, because the page I see is from the cache, the dialog element is not anymore on the page. If I don't add `data-turbo…
…
Related to the Turbo Page Cache issue discuss at the end of the video, `data-action="turbo:before-cache@window->modal#close"` was not working for me. After reading the documentation (https://turbo.hotwired.dev/reference/events#document) I replaced `window` by `document` and it…
I'd need to give it a try with the AssetMapper stack but lazy controllers with Stimulus + Turbo + Webpack work fine. So, my first guess is yes, this is a bug on AssetMapper
…not be loaded on any other pages that you navigate to !
This is what I see in my app.
Am I understanding this correctly ? Is there a workaround ? I assume the turbo team is aware of this ? I can't find much info on it.
Hey |mention:33328|,
It looks like you need to do something like this
```js
import { navigator } from '@hotwired/turbo';
class SomeStimulusController {
static targets = ['form'];
submit() {
navigator.submitForm(this.formTarget)
}
}
```
I hope it helps!
Hey Stuart,
I suppose you're talking about this comment? https://symfonycasts.com/screencast/turbo/intro#comment-33200
Thanks for sharing your solution with others.
Cheers!
```
An exception has been thrown during the rendering of a template ("The following keys are not valid for the importmap entry "@hotwired/turbo": "url". Valid keys are: "path", "version", "type", "entrypoint", "package_specifier".").
```
The suggested importmap code doesn't work anymore.
Hey |mention:37880|!
Morphing is alive and well on Turbo 8, though I admit that I don't have any real experience with it yet (not because it's bad or anything, I've just not been available!). If you have the `meta` tags, I…
What is the status on the morphing functionality? I have the latest turbo version but adding the meta tags in the head as per the documentation doesn't seem to do anything
Hello everyone,
I would like to describe a problem that I noticed when working with modals and AjaxForms and UX Turbo. I want to do the following:
In the website there is a button in the header that opens a modal/dialog - built as described…
Hello,
I am having a bit of a problem getting the content to load in the turbo-frame in the dialog. I followed the video, and when I click new voyage, the turbo-frame says completed, but there is nothing inside. I made sure to…
I got your hive five!
Hello, Turbo might be usefull but just one moment has not lighted in lesson. If you run some thing on page - JS loop counter, audio, video or WS/WSS connection - it would not be cancel whenever you go to another…
Hi @MolloKhan,
Thanks for your reply. Yes I am trying to get Turbo Drive and Frames working at my Easy Admin project. So there is no way to get the Turbo Drive or Frames working?
…the turbo-frame, the live action is redirecting to the same route (reloading the same page via the controller). So the turbo-frame element is in the returned HTML. But the entire page is reloaded from scratch, not only the changes in the turbo-frame…
Hey |mention:39473|
yes, the response just needs to return HTML wrapped in a turbo-frame element with the same ID as the one you want to replace
Cheers!
Hey |mention:15156|
That's unexpected. I believe your site is running so fast that Turbo finishes loading before your `waitFor()` call. IIRC the second argument of that method is the amount of milliseconds it should wait before it "gives up", you could set it…
x
687